What's up with ESPNOW?

Recurrent H/W and software problems
Post Reply
davepurola
Posts: 1
Joined: Sun Mar 14, 2021 2:55 pm

What's up with ESPNOW?

Post by davepurola »

I just loaded ANNEX 1.4.3 into a pair of ESP-12s modules. I have yet to make it work in STAND ALONE mode. If I connect to my router it seems to work BUT in the situation I'm going to use then there is NO router. Attached is the receiver and transmitter code. What I would like to know from the guru's is, WHat does the CONFIG tab look like for operation in stand alone mode.

----------------------------------------------------------------------------------------------------------------------------
'ESP-NOW receiver example

serial.mode 38400
PAUSE 2000

print
print "init " ; espnow.begin ' should print 0 if all OK

onEspNowMsg message ' set the place where jump in case of message reception

WIFI.APMODE "","",6
pause 2000

PRINT
print "Ipadd=";WORD$(IP$,1) ' will print only the IP address
print
print MAC$
a = WIFI.CHANNEL
print
print "channel: ",a
print

wait



message:

print "RX:"; espnow.read$; " from "; espnow.remote$ ' print the message

return

-------------------------------------------------------------------------------------------------------------------------------------

'ESP12S-TX1

serial.mode 38400

RECEIVER_MAC1$ = "8C:AA:B5:5A:46:6F" ' MAC address of the receiver(DEV.BOARD)
espnow.begin ' should print 0 if all OK
espnow.add_peer RECEIVER_MAC1$ ' set the address of the receiver
onEspNowError status ' set the place where jump in case of TX error

WIFI.APMODE "","",6
pause 2000
a = WIFI.CHANNEL
print
print "channel: ",a
print

reason = BAS.RESETREASON
SELECT CASE reason
CASE 0 : PRINT "Normal startup by power on"
CASE 1 : PRINT "Hardware watch dog reset"
CASE 2 : PRINT "Exception reset"
CASE 3 : PRINT "Software watch dog reset"
case 4 : PRINT "Software restart ,system_restart"
CASE 5 : PRINT "Wake up from deep-sleep"
CASE 6 : PRINT "External system reset"
END SELECT
print

'LM-73 REGISTER POINTER NEUMONICS
ADDRESS = &H49 'LM73-0,ADDRESS PIN FLOAT
TREAD = 0 'TEMPERATURE HOLDING REGISTER
CONFIG = 1 'CONFIGURATION REGISTER
UPPLIM = 2 'UPPER LIMIT HOLDING REGISTER
LOWLIM = 3 'LOWER LIMIT HOLDING REGISTER
CONTROL = 4 'CONTROL REGISTER
IDREG = 7 'ID REGISTER
SIGN = 0
TEMPERATURE = 0

a = 0

ADS1110_ADDRESS = &h48
volts = 0
d = 0
ret = 0
rate = 3
gain = 0
conf = 0
V = 0
POR = 1

i2c.setup 4,5' set I2C bus

' scale in volt
scale = 10.20 / 32768

MAIN:
GOSUB readport' initial read of port switch

gosub ADS1110_read ' read from the module

GOSUB READTEMP_LM73 'READ AND UPDATE TEMPERATURE FROM LM-73 (Degrees F. x 0.1)

gosub sendMessage
IF A = 0 THEN 'IF SWITCH IS CLOSED THEN, BACK FOR MORE
PAUSE 2000
' GOTO MAIN
ELSE
SLEEP 60 'IF SWITCH IS OPEN THEN DEEP SLEEP for 1 minutes
pause 5
ENDIF
' WLOG VOLTS,(VOLTS * scale),TEMPERATURE,RAW
GOTO MAIN

end

' ********************************************************************
sendMessage:
' ********************************************************************
D = volts * scale
espnow.write "Sensor1 Volt: " + str$(d, "%3.2f") + " Temp: " + STR$(TEMPERATURE, "%3.2f") + " State: " + STR$(A)
print "Sensor1 Volt: " + str$(d, "%3.2f") + " Temp: " + STR$(TEMPERATURE, "%3.2f") + " State: " + STR$(A)
RETURN

' ********************************************************************
status:
' ********************************************************************
print "TX error on "; espnow.error$ ' print the error
RETURN

' ********************************************************************
ADS1110_read:
' ********************************************************************
conf = &h90 or (rate << 2) or gain ' + disable comp
i2c.begin ADS1110_ADDRESS
i2c.write conf
i2c.end
pause 250

reread:
i2c.begin ADS1110_ADDRESS
i2c.reqfrom ADS1110_ADDRESS, 3
highbyteAD = i2c.read
lowbyteAD = i2c.read
configAD = i2c.read
' PRINT "A/D: ",((HIGHBYTEAD << 8) + LOWBYTEAD)
i2c.end
if configAD > 127 then 'wait for conversion to complete
print "awaiting conversion complete"
goto reread
endif
volts = ((highbyteAD << 8 + lowbyteAD) and &hffff)
if volts > 32768 then volts = volts - 65536
return

' ********************************************************************
READTEMP_LM73: 'READ AND UPDATE TEMPERATURE FROM LM-73 (Degrees F. x 0.1)
' ********************************************************************
TEMPERATURE = 0
POINTER = CONFIG 'CONFIGURATION REGISTER
i2c.begin ADDRESS
I2c.write POINTER
i2c.write &h7C 'full power mode/one shot mode
i2c.end

POINTER = CONTROL 'CONTROL REGISTER
i2c.begin ADDRESS
I2c.write POINTER
i2c.write &hE0 '14 BIT RESOLUTION (13 PLUS SIGN)
i2c.end
PAUSE 250

POINTER = TREAD 'TEMPERATURE HOLDING REGISTER
i2c.begin ADDRESS
I2c.write POINTER
i2c.end
i2c.reqfrom ADDRESS, 2
highbyte = i2c.read
lowbyte = i2c.read
i2c.end

POINTER = CONFIG 'CONFIGURATION REGISTER
i2c.begin ADDRESS
I2c.write POINTER
i2c.write &hFC 'shut down mode
i2c.end

TEMPERATURE = ((highbyte << 8) + lowbyte)
RAW = TEMPERATURE

IF TEMPERATURE > 32767 THEN
SIGN = 1
TEMPERATURE = NOT TEMPERATURE 'CHANGE SIGN IF NECESSARY
ELSE
SIGN = 0
ENDIF
TEMPERATURE = TEMPERATURE AND &hFFFF
'----------------- DO CONVERSION TO FAHRENHEIT -----------------------------
TEMPERATURE = TEMPERATURE * (1/((19200-0.0)/(302.0-32.0)))
IF SIGN = 0 THEN 'TEMPERATURE IS POSITIVE
TEMPERATURE = TEMPERATURE + 32'OFFSET '~320
ELSE 'TEMPERATURE IS NEGATIVE
TEMPERATURE = 32 - TEMPERATURE'OFFSET - TEMPERATURE
ENDIF
RETURN

' ********************************************************************
readport:
' ********************************************************************
PIN.MODE 14, INPUT' set pin 10 as INPUT
PAUSE 50
A=PIN(14) 'READ THE STATE
Return
Post Reply