Communication between a Arduino Pro Mini 8Mhz and ESP32
william-seaton opened this issue · 1 comments
Hi there,
In advance, I hate posting 'help me' in issues, but I don't really know where else to go for this, I'm quite stumped:
The ESP32 is a ESP32-WROOM-32U
I have an ESP32 and the 3.3v Arduino Pro Mini connected like this:
ESP32[12] <-> 100Ω <-> 100Ω <-> Arduino Pro 8Mhz[2]
|
1MΩ -> GND
They share a common ground bus and the run between the two is only about 5 inches.
I've confirmed they're connected using DigitalWrite and read on the two and I can confirm the wiring is correct, and I also can see when PJON is running that data is present using an LED connected to the bus (only momentarily connected to test that data was on the bus) because I do not have an oscilloscope.
Here is the exact code I'm using, and I'll also share the output:
Arduino Pro Mini:
#define SWBB_MODE 1 // 1.95kB/s - 15625Bd
#include <PJONSoftwareBitBang.h>
float test;
float mistakes;
int busy;
int fail;
PJONSoftwareBitBang bus(44);
void receiver_function(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info) {
// Do nothing to avoid affecting speed analysis
};
void setup() {
bus.strategy.set_pin(2);
bus.begin();
bus.set_receiver(receiver_function);
Serial.begin(115200);
};
void loop() {
Serial.println("Starting 1 second communication speed test...");
long time = millis();
unsigned int response = 0;
while(millis() - time < 1000) {
response = bus.receive();
if(response == PJON_ACK)
test++;
if(response == PJON_NAK)
mistakes++;
if(response == PJON_BUSY) {
busy++;
}
if(response == PJON_FAIL)
fail++;
}
Serial.print("Packet Overhead: ");
Serial.print(bus.packet_overhead(bus.last_packet_info.header) + 1);
Serial.print("B - Total: ");
Serial.print((unsigned int)((bus.packet_overhead(bus.last_packet_info.header) + 1) * test));
Serial.println("B");
Serial.print("Bandwidth: ");
Serial.print(test * (20 + bus.packet_overhead(bus.last_packet_info.header) + 1));
Serial.println("B/s");
Serial.print("Data throughput: ");
Serial.print(test * 20);
Serial.println("B/s");
Serial.print("Packets sent: ");
Serial.println(test);
Serial.print("Mistakes (error found with CRC): ");
Serial.println(mistakes);
Serial.print("Fail (no data found): ");
Serial.println(fail);
Serial.print("Busy (Channel is busy or affected by interference): ");
Serial.println(busy);
Serial.print("Accuracy: ");
Serial.print(100 - (100 / (test / mistakes)));
Serial.println(" %");
Serial.println(" --------------------- ");
// Avoid Serial interference during test flushing
Serial.flush();
test = 0;
mistakes = 0;
busy = 0;
fail = 0;
};
ESP32
#define SWBB_MODE 1 // 1.95kB/s - 15625Bd
#include <PJONSoftwareBitBang.h>
PJONSoftwareBitBang bus(45);
uint8_t content[] = "01234567890123456789";
void error_handler(uint8_t code, uint16_t data, void *custom_pointer) {
if(code == PJON_CONNECTION_LOST) {
Serial.print("Connection lost with device id ");
Serial.println(bus.packets[data].content[0], DEC);
}
};
void setup() {
bus.strategy.set_pin(12);
bus.set_error(error_handler);
bus.begin();
bus.send(44, content, 20);
Serial.begin(115200);
}
void loop() {
if(!bus.update()) // If all packets are delivered, send another
bus.send(44, content, 20);
};
Here is what I'm seeing on the serial monitors:
Arduino Pro Mini:
---------------------
Starting 1 second communication speed test...
Packet Overhead: 7B - Total: 0B
Bandwidth: 0.00B/s
Data throughput: 0.00B/s
Packets sent: 0.00
Mistakes (error found with CRC): 0.00
Fail (no data found): 10258
Busy (Channel is busy or affected by interference): 0
Accuracy: nan %
---------------------
Starting 1 second communication speed test...
Packet Overhead: 7B - Total: 0B
Bandwidth: 0.00B/s
Data throughput: 0.00B/s
Packets sent: 0.00
Mistakes (error found with CRC): 0.00
Fail (no data found): 9935
Busy (Channel is busy or affected by interference): 0
Accuracy: nan %
---------------------
Starting 1 second communication speed test...
Packet Overhead: 7B - Total: 0B
Bandwidth: 0.00B/s
Data throughput: 0.00B/s
Packets sent: 0.00
Mistakes (error found with CRC): 0.00
Fail (no data found): 10104
Busy (Channel is busy or affected by interference): 0
Accuracy: nan %
---------------------
Starting 1 second communication speed test...
Packet Overhead: 7B - Total: 0B
Bandwidth: 0.00B/s
Data throughput: 0.00B/s
Packets sent: 0.00
Mistakes (error found with CRC): 0.00
Fail (no data found): 10095
Busy (Channel is busy or affected by interference): 0
Accuracy: nan %
---------------------
Starting 1 second communication speed test...
ESP32:
Connection lost with device id 44
Connection lost with device id 44
Connection lost with device id 44
Connection lost with device id 44
Connection lost with device id 44
...
What I've tried:
I've tried building and uploading in PlatformIO and the Arduino. I also have tried setting TS_TIME_IN
to 0. I'm just kind of stuck, I'm wondering if there is an issue with timing?
I've also tried just connecting these two devices together using a jump, bypassing the resistors etc with no success.
Ciao @william-seaton thank you very much for your feedback.
Sadly 8MHz are not enough to generate or read nominally the pin.
Switch to 16MHz pro mini if you can.