E220 Remote Battery Switch; less than 100% working

Project is complex; will be used to control a remote switch using two Ebyte e900T30D modules, two esp32 devkit v1, KY002S MOSFET Switch, and INA226 Battery Monitor. Eveything is wired and working; however, both the Sender and the receiver sketches are producing only a few lines of the expected serial output lines.

Wiring has been traced with DMM and confirmed to be correct.

E220 Remote battery switch (Sender and Receiver code)

Wiring connections are included in the Github Gist.

Screen capture of only output from both Sender and Receiver

Regards,
William

I just flew low but very rapidly over your ~900 lines of code.

When you say this

void loop() {
  if (e220ttl.available() > 1) {

    //Do not see this returned
    Serial.println("Message arrived!");

are you meaning to point out an example of lines that are not produced? Do you mean never, or just not each time you expect?

Also, this jumped up

  if (data == 1) {
    int data = 1;
    Serial.println("\nBattery Switch is ON");
    Serial.println("ESP32 waking from Deep Sleep\n");
  }

and in a few other places you declare a new variable data and either don't use it or use it merely to pass the value you assign to it to another function.

This may be leftover, intentional or wrong, in any case it slows this reader down, are there others like it?

I won't be able to look closer until I am in the lab. Just now I'd say you have some kind of hardware issue, or some timing problem. Big help, huh? :expressionless:

I would start with simple sketches that only do the communication that is failing; fake or omit everything else. You may already have such pair leftover from your early experiments and tests.

HTH

a7

Yes, likely a left over. My first experience with Ebyte modules; it has been very challenging. Fatigue has been an issue too. Spent hours and days going over this code; before posting, little crossed eyed now. Good to have additional eyes on code; thank you 777.

I have verified module is putting out the RF, Wake on Radio and Message waveform:

WOR preamble and message from Sender

Post a datasheet link.

Purchased the MOSFET Bi-Stable Switch off of AliExpress, seller did not provide one; internet search failed to provide one.

Best I have for a datasheet:
KY002S Seller's description; hookup diagram and pinout

Setting the DESTINATION_ADDL to same address on both Sender and Receiver resolved the communications issues.

Have resolved all issues; remaining is wiring correction to make for the INA226 Battery Monitor.

Github repository for E220 Remote Switch; updated 05/24/2024.

William

Switching options in loop are working. There is an issue with Deep Sleep. When deep sleep is called; ESP32 goes to sleep, then it immediate wakes and goes to and executes setup. Can deep sleep be called from within the loop?

GitHub Repository: E220_Remote_Switch Receiver

Yes.

If it does not work, post your code.

Sender and ReceiverCode is complex; receiver code alone is 584 lines long.
Thought code might be too long to copy paste in the post; linked to GitHub Repository in post #7.

Due to length of "E200_Remote_Switch" project code; instead of copying and pasting here, code has been uploaded to Github Repository..

Prior issues have been resolved; remaining issue of "E220_Remote_Switch_Receiver.ino" is interuptExecuteded never occurs.

Project uses xReef's, E220 library; structures are used in the project code, along with E220 Wake on Radio to awaken radio and deep sleeping ESP32.

Breadboard wiring of E220-900T30D modules and ESP32 is included in the Github project upload.

Is 868 Mhz the correct base frequency for the e220-900T30D? Channel is set to 70 for 920 Mhz.

William

E220-Remote-Switch project has been completed; featuring E220, Wake-On-Radio with ESP32 Deep Sleep.

E220-Remote-Switch project utilizes two, Ebye E220-900T30D RF modules and two, ESP32 microcontrollers. Current project status: INA226 and KY002S have not been implemented in this update.

E220-Remote-Switch project code

E220-Remote-Switch Demo Video

Demonstation mode:

  1. ESP32 Receiver; push receiver reset button, this puts the ESP32 into deep sleep.
  2. ESP32 Sender; push sender reset button, this sends Wake on radio (WOR) message to wake ESP32 Receiver from deep sleep.
  3. Open browser to "http://10.0.0.27/relay"; this will create a web request for turning on battery power and start a countdown timer to turn off battery power, then put the ESP32 receiver into deep sleep.
  4. Next web request has a yet to be resolved issue; instead of turning on battery power, this web request ESP32 Sender sends a WOR message awaking the deep sleeping ESP32 receiver.
  5. Second web request is required to turn on battery power and start the countdown timer.

Three advantages of using the Ebyte, E220-900T30D is increased distance 10 km (estimated at power of 30 dbm) and Sleep current of 5 uA. E220-900T30D third feature is the ability to send a WOR message to wake up the receiving
transciver allowing second message; to turn on battery power.

Transmit current of 620 mA is almost instantaneous at 30dbm to send; up to 200 bytes, before dropping to sleep current. Receiving current; for a message, 17.2 mA. Current values are from "Ebytes E220-900T30D User Manual". Measured Standby current 11.8 mA. (E220, Always powered on). Ultilizing E220 Sleep Mode, Sleep current (E220, Always on) ranges from .54 uA to 97.33 uA measured!

E220-Remote-Switch video with sleep mode current monitoring

Xtensive help from ChatGPT, and Friends. Thank you xReef for your E220 library, community support, and E220 Support Forum.

William

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.