Hi all,
In Short: can GPIO13 on as esp32 Devkit 1 be connected to the RX pin (GPIO2) to wake from sleep on receipt of a Can Bus message?
Detail:
I am just about to order a PCB that I have been designing with much help from this forum for a NMEA 2000 can bus for a boat. I have one pin on the ESP32 Devkit1 still unused and it happens to be a 'touch' pin GPIO13. I was wondering if I could use this to wake from sleep so that I would be able to put the nodes into a low power mode when they are not in use. I have not gone into great detail with this yet and am pre-code but was thinking that it is worth adding functionality to the board that I could code in later.
The idea I have is that when the node is not in use it sleeps until a signal is received on the can bus. Could I just wire this pin to the RX pin of the Can Bus so that every signal would be mirrored on this pin. That way when asleep I could code the uC to wake when this pin receives a signal. I am still not sure how useful this functionality would be but since the boat runs on batteries any power saved could be important. The Can Bus will be responsible for switching lights, receiving sensor data, displays etc so will likely be quite busy when the boat is in motion but very quiet at night, for example. I presume I would start by coding for these quiet times to be sleep times for nodes and then look at clever ways of napping even in the busy times.
Thanks
my schematic:
pmagowan:
Hi all,
In Short: can GPIO13 on as esp32 Devkit 1 be connected to the RX pin (GPIO2) to wake from sleep on receipt of a Can Bus message?
Yes.
Let's say the ESP32 is in deep sleep and GPIO13 has been setup as an RTC pin that the ULP monitors for message traffic. When traffic is detected on RTC13, the ULP wakes the ESP32 main cores, which causes them to reset and wake up. During the time of the ESP32 reset the CAN message has been delivered and, when the main cores wake up there is no CAN message to process; cause its in the past.
Of course you might be able to program the ULP to receive the CAN message and store it for the main cores to process. You can program the ULP in the Arduino IDE using GNU legacy and MACRO code but you only get 2K of program memory. By storing the CAN buss message into RTC Fast RAM then main cores can access the data once they are awake.
See:
ESP32 API: API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation
ULP instruction set: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/ulp_instruction_set.html?highlight=ulp
ULP GNU legacy make: Page Not Found - ESP32 - — ESP-IDF Programming Guide latest documentation
Fantastic thanks. At the very least it seems reasonable to use the pin rather than leave it unconnected and since this is just a simple matter of joining it to the RX pin I might as well. It will probably be the last thing I start work on but having the option is great. I will change my PCB design