Giter Site home page Giter Site logo

esp-now's Introduction

ESP-Now

Updates:

  • If you're looking for something like ESP-Now but with instead of ESP to ESP with ESP to something else like a Raspberry Pi then checkout this alternative adhoc networking approach.

  • As of 19 Aug 2018 the latest ESP8266/Arduino code has fixed Issue 3408 and also added a deepSleepInstant function. This means an ESP-Now sensor can do the wakeup-send-sleep cycle in around 40 milliseconds, about an order of magnitude faster than previously and it should now get really good battery life. I've added a minimal example demonstrating this in espnow-sensor-minimal ***

ESP-Now is an interesting ESP8266 protocol that could be used for battery powered sensors. Its built on top of 802.11 vendor-specific action frames which enables sending data without having to first establish a WiFi AP to Station connection which is time consuming and so adds significantly to draining the batteries on each sensor wakeup.

I've given some examples of it before, here, however ESP-Now doesn't work with Wifi so a gateway receiving ESP-Now transmissions can't also connect to a Wifi network, so thats made it pretty impractical for most uses.

I've been playing about with ESP-Now again recently and come up with two workarounds for the Wifi co-existence problem. One is to restart the ESP8266 after receiving each ESP-Now transmission, the other is to use two ESP8266's - one as the ESP-Now receiver and the other as the Wifi gateway.

The first approach of restarting the ESP8266 might seem a bit clunky but it actually works ok. The restart takes a few seconds (most of the time spent reconnecting WiFi), so if there aren't too many remote ESP-Now sensors or the sensor transmissions aren't too frequent then the Gateway being regularly unavailable for a few seconds doesn't actually matter.

The second approach with using two ESP8266s is more complicated to set up but also more robust and allows higher throughput. I've used a simple serial link with the ESP-Now receiver simply writing the received data to the Serial port which another ESP8266 can read using SoftwareSerial. You could also try writing a more fancy I2C or SPI driver too.

These are some ESP-Now devices using this approach. A battery powered temperature/humidity/pressure sensor built into a LED light case and an ESP-Now to Wifi Gateway using the DIY USB powered ESP (described here).

Sample code for these are in this repository.

Alt text

You can see the data from that ESP-Now based BME280 sensor thats in my back garden in London here.

esp-now's People

Contributors

antelder avatar torntrousers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-now's Issues

espnow-sensor-timing.ino running on an ESP-01 does not dependably enter low power mode.

espnow-sensor-timing.ino running on an ESP-01 with ESP8266 pin 8 connected to ESP-01 PCB Reset pin does not dependably enter low power mode. the ESP-01 appears to draw 0.351mA while the ESP8266 is asleep (there is a power LED still connected). The espnow-sensor-timing.ino wakes up the ESP-01 according to the random time-out value as expected. However, occasionally the current will remain high at about 67mA.

Serial Gateway

Hello and thanks for making your work available.
Have you developed code for a serial gateway device (ie an ESP8266 receiving data from a number of sensor nodes and transferring them over the serial line to a server)?
I prefer to collect the data on a local server, so I do not need a networked gateway, and this might be easier to implement too.
I would like to have a few thermometers outside the home running on battery, this seems to be good use of esp-now.
Thank you.

Broadcast?

I know this is not an issue with your code, but I found no other contact information to discuss the following:

I'd like to implement a discovery function via ESP-Now, to avoid having to pre-configure MAC addresses in the source code of each device. For that, I'm trying to send broadcast packages to FF:FF:FF:FF:FF:FF. According to Espressif's docs, this is either supported or unsupported, depending on where you look.

I'm able to send packages to the broadcast MAC address, but I cannot get any device to receive those broadcast packages. Have you looked into broadcasting?

Serial bridge between NodeMCU and ESP01

Hi,

I really want to try this project, but so far I am not lucky.

I am trying to build a gateway for ESP-NOW (https://github.com/HarringayMakerSpace/ESP-Now) and I would like to get help with connecting two esp8266 (nodemcu + esp01) with serial link (for use as gateway).

enter image description here

What I done so far:

ESP01 ... NODEMCU
-----------------
3V3   ...  3v3
GND   ...  GND
CH_PD ...  3v3
TX    ...  RX
RX    ...  TX

The problem is that with this setup NodeMCU (and I think ESP01 too) is not booting (probably because TX is connected?). What's the correct way to connect two ESP8266 as described in ESP-NOW project?

NodeMCU is running this code:

https://github.com/HarringayMakerSpace/ESP-Now/tree/master/EspNowFromSerialGateway

ESP-01 is running this code:

https://github.com/HarringayMakerSpace/ESP-Now/tree/master/EspNowToSerial

ESP-NOW Security

Hi

I have note used encryption with my own keys but I read that there is a default key that is used if one is not supplied ?

Do I infer from that that ALL peer to peer communication is encrypted by default using the default key ? If so how secure would it be ?

Regards
mars000

Sensor device won't wake from deep sleep

I tried this with a pair of nodemcu 12E's and the one with the sensor goes to sleep and never wakes up. When it first sends data, it goes ok, returns a status = 0, then goes to sleep and never wakes back up. I don't see anything wrong with the code. I guess I don't understand how it is supposed to wake up.

bme280 init=60
temp=75.830002, humidity=18.812500, pressure=26.775942
This mac: CC:50:E3:DE:18:3A, target mac: 5c50e3de1428, channel: 4
send_cb, send done, status = 0
Up for 165 ms, going to sleep for 954 secs...

Any insight would be appreciated.

Q: ESPNow turnoff

Hi,
I am planning to use ESPNow with a (wind) sensor that I have to read every couple of second, so I do not want to (=it does not bring much) go into deep sleep, so I wonder if there is possible to turn off the ESPNow. I was thinking something like:

esp_now_deinit();
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();

//read sensor, and if needed turn on/initialize ESPNow and send the data

BTW: do you know how much power does it consume ESPNow (not sending data/sending data)?

TIA

ESP-NOW encryption

First of all, thank you for the good work you provide.
This is not an issue in your code, but this is the only I found to contact you, so my apologies for that.
There seems to be a lack of information in the documentation about how to set a key for the communication in ESP-NOW.
I have tried everything, and it doesn't seem to work, when I add the key the send callback still registers a value 0 for the status register, which implies that the receiver should receive data properly, yet it is not happening.
So have you tried using a key?
And if I use a NULL key does the data get sent unencrypted? or does it get encrypted but with a default key.
Thank you!

Reverse channel possible?

I have a remote control to transmit commands to a tank using ESP_Now. I want also to include a "telemetry channel which sends data from the tank to the remote control but was not successful. Did you try this?

Two ESP Serial connection example

Hi,

I am having good success with your examples, however, I am interested in using two ESP modules connected by a serial connection, as you describe in your readme text. Could you possibly post your example code?

I am having trouble understanding how to receive data via serial into memory.

Thank you.
Chris

Does esp_now_add_peer really make any difference ?

I've been playing with ESP-NOW on ESP8266 and found that b-directional communication works fine with and without me using esp_now_add_peer. Which made me think what does this function call achieve or do ? I can' seem to work it out....anyone know ? (the Espressif documentation is not so helpful)

BTW: I found the same situation with setting the WiFi channel using add_peer to have no consequence.

Any insight would be great ;-)

ESP-Now does work with WiFi

First good code for ESP-now functions

Recently I have tested with a 1-master 1-slave setup, master connected to WiFi ap.
as long as ESP-Now and WiFi operate at the same wifi channel, they both do work.

since ap channel is determined by ap gateway, the only thing we can change is ESP-Now channel. just connect to ap, then set the slave the same channel as the master's wifi_get_channel().

this could be done with a default init channel, after master connected ap, do the following on master:

wifi_channel = wifi_get_channel();
wifi_set_channel(default_channel);
for (int i = 0; i < 5; i++) {
//tell slave to switch wifi_channel
}
wifi_set_channel(wifi_channel);

on the slave, do:
in the recv callback:
wifi_set_channel(wifi_channel); //the wifi_channel is from master

Edit: after some experiments wifi_set_channel only last a few seconds at slave side, the only stable way to change channel on slave is by setting AP config wifi_softap_set_config_current(conf)

ESP-Now with one master device

Hi,
Thank you for good examples. I am just wondering before jumping extensive implementation. Do you guys think that this kind of scenario would be possible to implement with ESP-Now? So that I have various amount of battery powered ESP-Now enabled sensors which are sending data to one usb powered ESP-Now, from that one "master" ESP-Now, I can then push data over the Software Serial to "normal" ESP8266 which can then connect to normal wi-fi and for instance push values to MQTT.

What I am wondering, is it possible to have this kind of one "master" ESP-Now which then receive values from all others?

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.