search : MyHwLinuxGeneric.h parentheses declaration [-Wvexing-parse]
??? https://stackoverflow.com/questions/21624880/how-does-this-declaration-invoke-the-most-vexing-parse ???
search : MyHwLinuxGeneric.h parentheses declaration [-Wvexing-parse]
??? https://stackoverflow.com/questions/21624880/how-does-this-declaration-invoke-the-most-vexing-parse ???
So @Greg-Bowers .... you found the flaw?
hello @jkandasa
..... a little parenthesis!
( what's new in MyC )
https://github.com/mycontroller-org/server/releases/tag/development
I searched on the forum how to use ID255 but found nothing practical
https://github.com/mysensors/MySensors/blob/development/examples/PingPongSensor/PingPongSensor.ino
how to find a communication problem on a channel?
the solution is to check each link.
on the gateway : https://www.mysensors.org/build/advanced_gateway
add leds or a single one to visualize the dialog # Radio Traffic LEDs
(this function can also be used on a node )
on the gateway a dummy/virtual value can be created to simulate a probe (the result will tell us if the gateway is not at fault
additional information may not be useful
"Debug messages are sent to child ID 255"
https://github.com/mysensors/MySensors/blob/2.3.1/MyConfig.h#L77
Hello
what type of architecture do you use ?
(an example)
bus....... = Nodes <--- ? ---> Gateway <--- Usb ---> Controller
material = Atmega ..............arduinoUno.................Raspy4
software = MyS2.3.............MyS2.3 ....................Ubuntu/MyC2.x
?= RF RFM RS
"harmonic disturbance" https://www.electronics-tutorials.ws/accircuits/harmonics.html
(wired or wireless )
yes a problem more and more frequent with the saturation of the hertzian frequencies
which controller you use ? : https://www.mysensors.org/controller
congratulations for having found the solution
have a language translation problem or a bad formulation of me.
my question was what kind of gateway you used, but yes your solution is good.
but the solution that is "the linux terminal of raspi" to read the Logs is the best.
In my case my controller puts the logs in /opt/apps/mycontroller, reading the file gives useful information, but of course it's better with the options enabled in the gateway
#define MY_DEBUG
// #define MY_SPECIAL_DEBUG //maybe also ? (see the utility?)
Translated with www.DeepL.com/Translator (free version)
Hello
"I changed my wireles gateway (Wemos-D1 Mini) to serial. "... yes but what is it?
Arduino Usb Gateway?
reading the log files can be useful, their location is different depending on the system.
some info :
https://www.mysensors.org/build/debug
https://www.mysensors.org/build/parser
I don't think adding a timer function in "MyTransport.cpp" is a good thing,
Serial Gateway has many hours of flight and many people use it, there are many possible causes to your problem.
but thanks for this solution you give, it can be useful for others.
Waiting
"Waiting using the Arduino delay() command is not a good idea. " ... https://www.mysensors.org/download/sensor_api_20
utili:
https://forum.mysensors.org/topic/10386/what-is-the-good-wait-time
https://forum.mysensors.org/topic/9099/does-gateway-loop-required-wait-or-delay
@monte said in Replace 2.4GHz remote controllers:
"Mysensors fonctionne selon son propre protocole et ne prend en charge aucun produit commercial" yes
the beginning of a track can be useful for you ?
https://github.com/Yveaux/NRF24_Sniffer
https://arduino.stackexchange.com/questions/39348/decoding-2-4g-rf-remote-controller
Your question raises many problems, but a simple solution may be possible
In the creation of a home automation system there are two basic philosophies.
for your problem how to have a "degraded mode" in case of scratch.
some reading ... links :
the keyword, the thread: Sending data
https://forum.mysensors.org/topic/7841/relay-actuator-send-periodic-status-as-heart-beat
https://forum.mysensors.org/topic/6948/synchronising-light-switch/2
Hello to you
"MY_TRANSPORT_WAIT_READY_MS. Very useful. You can tell a node to try connecting to the gateway for X seconds, but if it fails, it should just carry on. I usually set this to 10000 so that it will try connecting to the network for ten seconds, and then just continue starting the node. The default is 0, meaning that if a node can't connect to the gateway it will never reach the loop() portion of your code!" API 2.0
thanks for the feedback.
can we say that with cheap material (no-name) we pay the rest of the bill later?
(what was the model??)
look here https://www.home-assistant.io/integrations/mysensors#custom-unit-of-measurement
the "CUSTOM UNIT OF MEASUREMENT" part
tests with type V_LEVEL or V_UNIT_PREFIX
if it works the problem comes from the version of MySensors Arduino library ?
Library API
tries to create a virtual value, a false sensor.
"It worked for about 6 months" ... wear and tear or a case of a component ???
courage you will find
( it is difficult to help a person on a material problem without seeing anything )
Yes, this is a good idea.
but not with an ethernet switch/hub, only an ethernet crossover cable.
??
https://copperhilltech.com/wt32-eth01-serial-to-ethernet-module-based-on-esp32-for-iot-applications/
yes also here (France) there is still some person with the mask, a remnant of the trauma?
the role of the mask was to gag us.
a virus is not stopped by a piece of paper on the face, it's in the air, it settles everywhere.
The only solution was to go out naked and take a shower when we got home.
@monte said in Boards esp8266 v3.1.0 or Newer Doesn't Work with MySensors:
il existe tellement de solutions bon marché et faciles pour ce que font mysensors
as rich in possibilities as this does not exist
a line of the examples given in the sketches for the use of RS485 can be a source of problem
(it's my case, I use Pin2 or3 for a long time )
...
// Define this to enables DE-pin management on defined pin
#define MY_RS485_DE_PIN 2
(2 or 3 is an interrupt pin for a Uno)
...
avoided interrupt pins.
the pin 10 is a good thing
...
compiled: Jan 27 202312:42:11
01/27/2023 12:42:11
RTC lost confidence in the DateTime!
RTC is the same as compile time! (not expected but all is fine)
01/27/2023 12:42:11
19.25C
01/27/2023 12:42:14
19.25C
-------- power loss -----
RTC communications error = 4
01/01/2000 00:00:00
0.00C
RTC communications error = 5
01/01/2000 00:00:00
0.00C..
------------- return power supply +5v ----
RTC lost confidence in the DateTime!
01/01/2000 00:00:12
19.50C
RTC lost confidence in the DateTime!
01/01/2000 00:00:15
19.50C
...
https://forum.arduino.cc/t/librairie-makuna-freez/1081415/34
For your information, RTC ... DS323x
the library provided with Mysensors can be blocking on loss of Com or lack of power supply of DS3231 module.
new features are added to wire
https://github.com/Makuna/Rtc/discussions/151
... the most with the makuna version, it gives error messages, and restarts after a loss of Communication or Power.
the terminal test is copied.
nice realization, clean and modern
can be already used, but foresee a protection of the OLED display, yes it is "marked" easily
on my Gateway GUI I have the function ( différente suivant la librairie )
oled.ssd1306WriteCmd(SSD1306_DISPLAYOFF); // set the OLED display to OFF
a key press on the keyboard and the screen turns on for an hour.
Dual Transport (dual bus)
Hello
Yes a Gateway with several buses or a Node with two different buses would be a good thing.
You may have seen the post and the version of @tekka
https://forum.mysensors.org/topic/11135/something-s-cooking-in-the-mysensors-labs?_=1674118354490
. maybe not a problem for you
"tekka's personal fork from the MySensors 2.4 branch and has not been updated"
https://github.com/tekka007/MySensors/tree/UpdateMultiTransport
Thanks for the feedback
For those who think MySensors is finished, the proof is in the pudding, thousands of systems are functional
bravo
a very complete scheme, yes there are so many possible architectures, it's not easy to see from a distance.
Good discovery of MySensors (a good old bottle)
Hello
I didn't understand very well, do you already have a mysensors network with nodes in use?
How does Domoticz dialogue with mysensors nodes?
Which Mysensors sketch and on the GatewayUSB+Oled-Key?
hello
FS1000A est pas sérieux pour la gestion de chauffage.
https://www.mysensors.org/build/connect_radio#nrf24l01+-&-arduino
Hello @Konrad-Winiarski and best wishes for 2023
if you have time you can tell us more about the architecture you have chosen.
the part
yes examples for a small test installation
thanks
https://forum.mysensors.org/topic/11513/corrupted-data-from-rs485-sensor-node/3
a news (which is not new)
MySensors Nodes values are going up on Grafana
beware, this is a bit like false advertising, not everything is functional
thank you
.... and a happy new year to MySensors users
a test with a numerical value
int val = 850 ;
#define val_CHILD_ID 8
MyMessage msgval (val_CHILD_ID, V_PERCENTAGE);
//----- reception MyS ------------
void receive(const MyMessage &message) {
if (message.getType() == V_PERCENTAGE) {
if (message.sensor == 8)
{
val = atoi( message.data );
}
}
send ( msgval.set(val) );
}
Hello
.... look around a bit here, maybe good.
https://forum.mysensors.org/topic/11089/send-a-text-to-node
https://forum.mysensors.org/topic/10488/homeassistant-mysensors-notify-does-nothing-alternatives
https://www.home-assistant.io/integrations/mysensors#notify
Please let us know if you have any test results.
good code
the Node To Node must be seen as a Gateway to node
the controller is not mandatory.
so we rethink the topology.
Gateway (node0) <---> Node1 <---> Node2 <---> 3.. 4...
The Gateway in 2022/2023 must be used, how to do!!?!! ...... a Node Useful
(yes an old message, but to refresh the ideas )
happy holidays to you all
hange of direction, we forget the problems mentioned above, another bookstore.
The project : reading of the values of an Electric meter with sending of the values on the bus RS485, from Node To Node.
. ATmega328 (uno) / TIC demodulator / RS485 shield
. ATmega328 / OLED / RS485 shield
(DFRobot_RS485_Shield_SKU__DFR0259)
the latest version of the MicroQuettas
LkyRx_10e.zip (9.4 KB)
... functional project
yes HA or (Hassio ) and not very friendly with MySensors.
the "Persistence" function of the sensors and the rewriting of the sketches ( for the validation of the messages) and a constraint.
Persistance
No MyS is not dead, we are La!
and for "Do I have to rewrite all my scripts, automations, models, etc..." ... it is perhaps the safest, cleanest...
give us the result! Ask on the HA/Hassio forum for a solution?
you are in mode #define MY_NODE_ID "static" for the nodes??
hello
yes the title of the post is not clear (I did not find another one)
it means, how to regulate the sending of messages on the Controller/Gateway.
History:
In test for the reading of the Electric consumption, I found many sketches and some with MySensors.
Here is the one of restraint: texte du lien
The Problem and a burst of dialogue from the Messages, too much dialogue.
On the sketch there is a line with : SEND_FREQUENCY_FULL
but it doesn't work, nothing in the *.cpp and *.h files either
I think that when a Library passes from hands to hands, some elements are deleted in part.
Question :
how to delay the sending of the values ?
which choice ?
. a [ SendTime = currentTime - previousMillis ] well placed in the program ? (it didn't work )
. planting [Wait(time)] (nothing grows)
. use Echo received and delay the send ? Echo receive
. contact Henry Walton Jones Jr. to learn more about the origin of the library?
(I don't have his number, and he's getting too old)
The Genesis of the librayry ? : LibTeleinfo Gitub
Thank you for your help
Yes, the toggle system is the best.
Tilt
but be careful, the condensate is very aggressive, their pH, an acidic liquid.
so no metal.
Ph
Here's an info: Why condensing boilers do not guarantee an efficient operation. : a link
the best of all worlds : a link link
bravo and good explanation
good to show that Arduino "8bits" and MySensors can do things simply, without gas factory
an extensible basis for further input/output
(door contact - relay control ...etc )
Thanks
https://forum.mycontroller.org/
integration of motioneye in MyC
Base OdroidC2/Armbian buster et Cam arducam (libcamera)
"Unfortunately the Commotion Project appears to be somewhat dormant. Their GitHub repository has not had any changes made since 2018, and the blog on their site has not been updated since 2015." https://jessehirsh.com/future-fibre-the-commotion-wireless-project/
Yes commotion is dormant, no more activity on gitHut but maybe another open source system has taken over ??? https://jessehirsh.com/future-fibre-telecomunicaciones-indigenas-comunitarias/
https://commotionwireless.net/docs/cck/networking/learn-wireless-basics/
wait (5);
c'est mieux ( pas d’interruption du pgm)
Hello
CAN Bus is still functional, and no problem.
a question : is it possible to implement the use of 2 CAN Module on the same Gateway.
2 CAN bus or RS485 + CAN
as for the RS485 in example for a Mega2560 board
MyConfig.h
......
* Example: @code #define MY_RS485_HWSERIAL Serial1 @endcode
*/
//#define MY_RS485_HWSERIAL (Serial1)
maybe this can be useful : https://forum.mysensors.org/topic/6948/synchronising-light-switch
I use it with version 1requestState or 2 requestTime() on some sketches
(I modified the structure, moved some parts to functions to make it more readable )
here can be the beginning of an answer:
https://forum.mysensors.org/topic/812/realtimeclockdisplaysensor-ino-no-fetch-time-from-controller
"I don't know where to start," ... in a chain there are
links, see which one is at fault
"defective" since the migration from serial to mqtt" ...? what does it mean?
I dialogue with you, but without really knowing, just to create a chain reaction of ideas
maybe others have an idea !??
Translated with www.DeepL.com/Translator (free version)
Hello
can you tell us more about your mysensors architecture.
see the chain of elements, hardware and software.
your message is about : Mqtt 'mosquitto? - OpenHab - Arduino" uno?"
hello
did you find some time to add the CAN bus error feedback?
the 2 and 3 is good, enough
and give me the procedure for the sketch
sorry for the alert.
it was an error in the gateway sketch
a ... #define MY_WITH_LEDS_BLINKING_INVERSE... duplicate, is misplaced
désolé
go to a fourth node
(Gw0 - Nodes 55 56 57 58 )
"Are my ideas good" .. yes yes c'est tout bon
"It will not flash the diodes in case of communication problems" ... it's not a problem, Christmas is still far
But yes a counter that increments is a good thing.
what do you want me to test ????
bool transportSanityCheck(void)
{
return (CAN0.getError()==CAN_OK)
}
The "radio guy" opinion would be great.
((I'll look for possible help ). )
Re-Edit
hal/transport/CAN/MyTransportCAN.cpp
bool transportSanityCheck(void)
{
// not implemented yet
return true;
}
Edit
I searched the web, and using SNR RSSI with the CAN bus is a dead end.
https://www.thethingsnetwork.org/docs/lorawan/rssi-and-snr/
The original idea was: how to check the status of the CAN bus.
. is there any dialogue ?
. are there any messages?
of course this can be done with MySensors.
But to get as close as possible to the communication channel (the CAN bus) I thought it was easy to do.
this is by reading the post of bricoleau here
text french
that the idea came to me.
and also because you suggested it to me
yes we have to beat the iron when it is hot, and my time available for the computer will soon be reduced (purchase and work of a house)
I appreciate very much your explanatory note, thank you
I activated the 16Mhz in the sketch, and put it back in the library
#define MY_NODE_ID 57 /*Node en ID static*/
#define MY_CAN
#define CAN_CLOCK MCP_16MHZ
Thank you for this clarification.
(yes translator and my neuron it gives crooked dialog)
"If I have missed a relevant property, please let me know."
The list of #define go up for the MySensors sketch .
( if I'm not mistaken ?)
***for MCP_CAN_lib **************** MyConfig.h line 280 to 315
CAN_INT // Pin for interrupting an incoming message.
CAN_CS // Chip selection pin.
CAN_SPEED // Transmission speed. The allowed values can be found in mcp_can_dfs.h
CAN_CLOCK // Can clock. Allowed values can be found in mcp_can_dfs.h.
CAN_BUF_SIZE // Assembly buffer size. As long messages can be split and arrive mixed with other messages, an assembly buffer is needed.
**** for MyS **************** MyConfig.h line 2492 to 2494
MY_CAN // Set this to use the CAN wire transport for sensor network communication.
MY_DEBUG_VERBOSE_CAN // Set this for verbose debugging printouts related to the %CAN driver.
can be added, for testing and controlling the CAN bus
#define CAN_MSGAVAIL
#define CAN_OK
#define CAN_CTRLERROR
Thanks
return of the last 24 hours .
CAN bus no error, good dialogue, no hole in the measurements and commands.
the hardware base on the bus is :
gateway + node 55 + node 56 .
I will add another node 57.
I think to go until 6 nodes
I just did the test, switch to 16Mhz in the file MyConfig.h
it works well, I have no error
#define CAN_CLOCK MCP_16MHZ
I didn't think it was possible, is it incompatible?
overwritten the values of the file MyConfig.h
thank you for the information
" I would suggest doing a long term test to see if it is stable." yes I will stress it to see the weakness
".. If it is stable, try to use it in real use cases." yes that's the point
One last question
I'm going from 8Mhz to 16Mhz (in development/MyConfig.h on line 306)
question: can you explain how I can bring up in the sketch the parameters that are related to the MCP_CAN_lib library
it should not be complicated for me it is only text to insert ???
an example with the #define CAN_CLOCK MCP_8MHZ
Thanks Adam Slowik
http://learntohackit.com/intro/# it can be useful information ???
Gateway Logs on MyController
(CAN Bus and RS485 Bus)
two separate files
CAN log
RS485 log
files split in parts :
A : gateways startup
B : reboot of the gateways
C : launch of MyClock Nodes (id23 and id55)
D ; periodic refresh requestTime(receiveTime)
E ; send value (1700 and 2100)
(I have prepared the work for you to read)
a 1st analysis
Adam Slowik bravo
I test what now???
the ACK ??
Oh yes, I have to check the disconnection of the nodes.
The Gateway gives me the impression that the information does not go back to MyC if a Node is off ???
a test with DHT22 probes.
the values go up well on MyC
real decimal values
here is a screen shot
I have to find another type of probes, the DHT22 give me losses, or my sketch is to review
ReEdit
error
I got excited too fast
the values are not refreshed.
I look better
ReRe-edition
I made a mistake, as I play a little too much with MyController, I add and remove gateways from nodes and other salads.
and well in the end it makes no sense
I cleaned up the Yaml files of MyC and it's better
#define MY_DEBUG_VERBOSE_CAN .....yes yes I already tested it, it's very good.
(a very useful function)
..go to
Bravo
sendSketchInfo(" text ...."); and well up
requestTime(receiveTime); and functional
Ahhhhhh Lovely this is great
I offer the coffee crossing
(what was the problem ??? )
After the test on the Digital I/O of the Nodes ,
now I test the Analog I/O
a Super Thank You @Adam-Slowik
what would you like as a novelty ???
" MySensors is dead ?" ... No, in my house it is still alive.
but it's true you are right to ask the question.
the programmers, the creators are always The ?????
what!? bought by the competition so that MySensors does not evolve any more? it makes damage to the commercial product
in the sketch I added lines to visualize the buffer data
log IDE :
newTime:0 -------------------------------------------
Extended ID: 0x0410FF00 DLC: 8 Data: 0x00 0x00 0xFF 0x0A 0x23 0x14 0xFF 0x00
88010 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
Extended ID: 0x05103700 DLC: 7 Data: 0x00 0x00 0x37 0x02 0x13 0x01 0xFF
Extended ID: 0x06303700 DLC: 8 Data: 0x00 0x00 0x37 0x52 0x03 0x01 0xFF 0x31
newTime:0 -------------------------------------------
I stop for me, I pause for 1 day or 2
frequency change
with 16Mhz I have a NACK
// #define CAN_CLOCK MCP_16MHZ
105 TSM:FPAR
18107 ?TSF:MSG:SEND,55-55-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=4,st=NACK:
newTime:0 -------------------------------------------
time current:0 -------------------------------------------
20115 !TSM:FPAR:NO REPLY
20117 TSM:FPAR
20119 ?TSF:MSG:SEND,55-55-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=5,st=NACK:
// #define CAN_CLOCK MCP_8MHZ
8004 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
28014 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
28019 TSF:MSG:ECHO
newTime:0 -------------------------------------------
time current:0 -------------------------------------------
38005 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
38016 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
I think the dialogue is good
but the problem is the length of the storyline
a part of the dialog on the IDE terminal for both types
CAN and RS485
- IDE terminal sur RS485 :
4066 TSF:MSG:ECHO
4132 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=10,sg=0:1655285320
8018 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
8054 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=0,sg=0:
8058 TSF:MSG:ECHO
8111 TSF:MSG:READ,0-0-22,s=255,c=3,t=1,pt=0,l=10,sg=0:1655285324
newTime:1655285324 -------------------------------------------
- IDE terminal sur CAN :
22224 MCO:REG:REQ
22226 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=0,st=OK:2
22233 !MCO:PRO:RC=1
22235 TSF:MSG:READ,0-0-55,s=255,c=3,t=27,pt=1,l=1,sg=0:1
22240 MCO:PIM:NODE REG=1
28004 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
28014 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
28019 TSF:MSG:ECHO
newTime:0 -------------------------------------------
sketch
void receiveTime(unsigned long controllerTime) {
if (receiveTime) stateCom = true ; else stateCom = false;
newTime = controllerTime;
" " ....
Serial.print(" newTime:"); Serial.print(newTime);
no it stayed on 8Mhz ?
I didn't modify anything (the other sketches work)
But I just looked at the quartz and it's 16M!! (SW-65-16M)
I am lost
https://www.gotronic.fr/art-module-bus-can-sbc-can01-28405.htm
but on the doc there is :
The 8000000 stands that the MCP2515 operates with a clock of 8 MHz. This
depends on the quartz used and may need to be adjusted.
error
on the official doc it's a 16Mhz like mine.
so 8Mhz or 16Mhz?
and why does it work with the previous sketches?
@Adam-Slowik "Could you post the CAN version here?"
it's the same, except that the bus is not rs485 but CAN
......
........
#define MY_NODE_ID 55 /*Node en ID static*/
#define MY_CAN
#include "SSD1306Ascii.h"
........
.....
but I'll go back to PaulStoffregen's Lib <TimeLib.h> to see if I can simplify the basic sketch of MySensors
I tested my sketch with clock and OLED to see
bah No the time is not up
I give this information for an overview, it can help for the continuation (but not to give you work )
The listing of the messages of mySensors
test with "void receiveTime" function (without RTC clock)
https://forum.mysensors.org/topic/4809/real-time-clock-module-lcd-display-and-controller-time/8?_=1655208396048
..........Log MyC - terminal ssh .........
2022-06-14T14:01:45.115+0200 recd 0;255;3;0;9;65310350 TSF:MSG:READ,55-55-0,s=255,c=3,t=1,pt=0,l=0,sg=0:
2022-06-14T14:01:45.119+0200 recd 0;255;3;0;9;65310356 TSF:MSG:ECHO REQ
2022-06-14T14:01:45.127+0200 recd 0;255;3;0;9;65310360 TSF:MSG:SEND,0-0-55-55,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
2022-06-14T14:01:45.127+0200 recd 55;255;3;0;1;
2022-06-14T14:01:45.146+0200 sent 55;255;3;0;1;1655215305
2022-06-14T14:01:45.160+0200 recd 0;255;3;0;9;65310394 TSF:MSG:SEND,0-0-55-55,s=255,c=3,t=1,pt=0,l=10,sg=0,ft=0,st=OK:1655215305
..........Log MyS - terminal IDE .........
time current:0 -------------------------------------------
58007 TSF:MSG:SEND,55-55-0-0,s=255,c=3,t=1,pt=0,l=0,sg=0,ft=0,st=OK:
58017 TSF:MSG:READ,0-0-55,s=255,c=3,t=1,pt=0,l=0,sg=0:
58022 TSF:MSG:ECHO
avec Bus RS485
..........Log MyC - terminal ssh .........
2022-06-14T14:22:41.265+0200 recd 0;255;3;0;9;72000090 TSF:SAN:OK
2022-06-14T14:22:41.274+0200 recd 0;255;3;0;9;72000096 TSM:READY:NWD REQ
2022-06-14T14:22:41.298+0200 recd 0;255;3;0;9;72000115 ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
2022-06-14T14:22:41.917+0200 recd 0;255;3;0;9;72000736 TSF:MSG:READ,22-22-0,s=255,c=3,t=21,pt=1,l=1,sg=0:0
2022-06-14T14:22:41.920+0200 recd 22;255;3;0;21;0
.........Log MyS - terminal IDE .........
time current:1422 -------------------------------------------
423956 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=1,l=1,sg=0:0
423962 TSF:MSG:BC
424008 TSF:MSG:SEND,22-22-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
requestOn-----------------------------------------
@Adam-Slowik "Can you push your patch to my repository? " .... I don't know how
On the CAN principle
@Adam-Slowik "Based on this id, the filters are configured to remove all messages not intended for the current node. This way, if the gateway wants to send a message to the node with id = 51, only the node with that id receives that message." ... yes, that's how I see it.
another way to say/explain it.
"The philosophy of CAN is to constitute a messaging system.
The messages (the letter) send on the CAN Bus (the post office), distributed by the CAN Bus (the letter carrier).
Each (letter) have each an identifier (stamp of the post ) that ... identifies it.
And put in the right mailbox (the MCP2515) according to the choice of filter/mask ( color, scent? ) of the letter."
So there are two "stratum" of dialogue / work.
The idea is to relieve the Nodes of unnecessary work/effort with the risks that this brings. Less letter to open
@Adam-Slowik "... my modules and arduinos are buried in a box in my attic..." ? Arduino 8bit and MySensors is over for you?
( if it's a personal / family reason don't say anything )
"Can you provide logs (gateway/node) from the reset scenario. It would be great to have these logs for RS485 and CAN so I can compare them."
Released today 2 gateways connect to MyController
with connect, a UNO with the basic sketch "RelayWithButtonActuator_base.ino" (slightly modified)
with ... a Led and a Switch, for each bus.
The Listing split in several parts
"Log of the IDE and MyC for the two types of bus (node34 and node 54), CAN and RS485.
- Listing Action RESET with MyController
2 parts for CAN
and
2 parts for RS485
and
- Listing Action On/Off on the node switch or with MyController
4 parts for CAN
and
4 parts for RS485
No error on the Reset, it works fine, an error from me.
Oh yes, I even found an error
the sendSketchInfo("test xxxxx", "1.0"); is not up
see the end of the video
video
....I will answer the other question tomorrow.
test with the digital output inputs of 2 Arduino on CAN Bus.
a proof in video that it is functional
all is not functional, on the end of the video, the reset or reboot does not work, (but functional with the RS485 bus)
.... to follow
(now the Analog values, decimal to test )
I would like to test the Node to Node with the filtering.
a question : is it difficult to put the filters on the MySensors sketch ???
there are still MySensors on the forum ???
if yes, a help for Adam Slowik would be a great thing.
implement it in MyS Yes Yes
Thanks
a topo of the day
on the hardware side, I got screwed with an arduino pin that became too soft, too dilated, look for an hour before understanding why no dialog.
Otherwise, on the Gateway side, no problem, MyController recognized well.
and CAN_Switch.ino is good too, my Widget on MyC switches well on the switch change.
listing of the dialog pour le Node 51 (set up in a fixed place )
coter log from MyC:
2022-06-11T18:49:35.167+0200 recd 0;255;3;0;9;1482640 TSF:MSG:READ,51-51-0,s=4,c=1,t=16,pt=1,l=1,sg=0:1
2022-06-11T18:49:35.170+0200 recd 51;4;1;0;16;1
2022-06-11T18:49:35.179+0200 recd 0;255;3;0;9;1482653 TSF:MSG:READ,51-51-0,s=255,c=3,t=21,pt=1,l=1,sg=0:0
2022-06-11T18:49:35.182+0200 recd 51;255;3;0;21;0
coter IDE from MyS:
67889 TSF:MSG:BC
68197 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
68203 TSF:MSG:READ,0-0-255,s=255,c=3,t=20,pt=0,l=0,sg=0:
68208 TSF:MSG:BC
68836 TSF:MSG:SEND,51-51-0-0,s=255,c=3,t=21,pt=1,l=1,sg=0,ft=0,st=OK:0
68843 MCO:SLP:MS=5,SMS=0,I1=255,M1=255,I2=255,M2=255
68848 TSF:TDI:TSL
68849 MCO:SLP:WUP=-1 ........ it is incomplete
well now we have to calm down the CAN bus dialog, the Rx/Tx Led of the gateway looks like a Christmas tree
tomorrow I'll test a CAN_Switch version2 sketch
https://sourcecodeartisan.com/2021/03/06/invalid-suffix-on-literal.html
for the Error code it is
a requirement in C++ 11 (or later).
lines 163 and 228 modify and error resolved
.../hal.transport/CAN/MyTransportCAN.cpp
CAN_DEBUG(PSTR("CAN:SND:CANH=%" PRIu32 ",ID=%" PRIu8 ",TOTAL=%" PRIu8 ",CURR=%" PRIu8 ",TO=%" PRIu8 ",FROM=%" PRIu8 "\n"), header, messageId, totalPartCount,
CAN_DEBUG(PSTR("CAN:RCV:CANH=%" PRIu32 ",ID=%" PRIu32 ",TOTAL=%" PRIu32 ",CURR=%" PRIu32 ",TO=%" PRIu32 ",FROM=%" PRIu32 "\n"), rxId, messageId,
a start of error messages return (on both sketches)
IDE version 1.8.19
for CANSwitch.ino
the message returns me to the line
MyTransportCAN.cpp --->
163 : ",TOTAL=%"PRIu8",CURR=%"PRIu8",TO=%"PRIu8",FROM=%"PRIu8"\n"), header, messageId, totalPartCount,
228 : ",TOTAL=%"PRIu32",CURR=%"PRIu32",TO=%"PRIu32",FROM=%"PRIu32"\n"), rxId, messageId,
the one copy (a part) of the IDE
In file included from /home/mci/Arduino/libraries/MySensors-development/MySensors.h:395:0,
from /tmp/arduino_modified_sketch_39381/CANSwitch.ino:43:
/home/Arduino/libraries/MySensors-development/hal/transport/CAN/MyTransportCAN.cpp:163:17: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
",TOTAL=%"PRIu8",CURR=%"PRIu8",TO=%"PRIu8",FROM=%"PRIu8"\n"), header, messageId, totalPartCount,
^
/home/Arduino/libraries/MySensors-development/hal/transport/CAN/MyTransportCAN.cpp:163:32: war......
^...
/home/Arduino/libraries/MySensors-development/hal/transport/CAN/MyTransportCAN.cpp:228:18: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
",TOTAL=%"PRIu32",CURR=%"PRIu32",TO=%"PRIu32",FROM=%"PRIu32"\n"), rxId, messageId,
^
/home/Arduino/libraries/MySensors-development/hal/transport/CAN/MyTransportCAN.cpp:228:34: warni.....
Hello
to save time, you can tell me more about the configuration of MCP_CAN_lib
not all settings are shown on the MyS sketch
here in an example https://github.com/coryjfowler/MCP_CAN_lib/blob/master/examples/CAN_receive/CAN_receive.ino
there are some parameters to adjust
or the filters https://github.com/coryjfowler/MCP_CAN_lib/blob/master/examples/Extended_MaskFilter/Extended_MaskFilter.ino
can you indicate me the files in question ???
(I think I have found but to confirm)
to make it clean
thanks
"you can choose a different library"
I like this freedom of choice, my questioning is not necessary
"I would really appreciate your comments"
yes yes in 4 to 5 days, theoretically
Finally a high reliability Wired Bus for MySensors with the MyS protocol which is extraordinarily rich.
(the RS485 bus is good, but the cables/wiring must be more rigorous and the management of collisions more delicate for X Nodes, and the CAN bus is a good field bus )
Hello
thank you for the answer
questions:
which CAN library did you start on,
mcp2515.h or mcp_can.h ...etc
the management of Float values is also managed ?
(numbers with decimals )
like this library which manages Floats https://github.com/pierremolinaro/acan/search?q=float
and of course any CAN card is managed, like this one https://www.gotronic.fr/ori-module-bus-can-sbc-can01-28405.jpg
I prepare another test computer for the installation of your version
Translated with www.DeepL.com/Translator (free version)
a request for information, how to do :
to add the CAN transport you have to modify the files or replace them with what exists ?
I will maybe test the work of AdamSlowik
good evening
again a new sketch for the "void receiveTime" function
(without RTC clock)
a video "https://www.casimages.com/v/RSWTNb-vokoscreen-2022-05-24-19-33-49.mp4.html"
/*
* LIBRAIRIE:
* MySensors v2 : https://github.com/mysensors/MySensors
* TimeLib.h : https://github.com/PaulStoffregen/Time
* SSD1306Ascii.h : https://github.com/greiman/SSD1306Ascii
*
* MATERIEL:
* Arduino Uno
* -Afficheur OLED 0,96" I2C TF052 / circuit SSD1306.
* bus TTLModule RS485
*
* REVISION HISTORY
* base de Henrik Ekblad 2013-2015 et autres :)
* ajout bus RS485 et OLED
*
* DESCRIPTION
* demander Date et Heure au contrôleur et l'affiche sur ecran OLED
* Request date and time from the controller and display it on OLED screen
*
* Connectique i2c:
* Arduino : A4 A5
* OLED : SDA SCL
*
*/
//-- The sketch uses 11932 bytes (36%) ----global variables use 839 bytes (40%)-----------
//-
//------------ 2022 ----------------------- Fonctionnelle avec MyC et MyS-------------------
//#define MY_DEBUG /*Enable debug prints to serial monitor*/
#define MY_TRANSPORT_WAIT_READY_MS 3000 /*Timeout (ms) pour mis en Com.(0 pour aucun)*/
#define MY_NODE_ID 22 /*Node en ID static*/
/* ----- Module RS485 ----*/
#define MY_RS485 /*Apl du transport RS485 (protocol?)*/
#define MY_RS485_DE_PIN 2 /*Cmd DE pin*/
#define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/
//#define MY_RS485_HWSERIAL Serial1 /*pour port Serial autre*/
#include "SSD1306Ascii.h"
#include "SSD1306AsciiAvrI2c.h"
#include <MySensors.h>
#include <TimeLib.h>
#define CHILD_ID 22 /* MyS numero du Node*/
#define I2C_ADDRESS 0x3C /*i2c adresse*/
#define RST_PIN -1 // Define proper RST_PIN if required.(oled)
SSD1306AsciiAvrI2c oled; //type de com oled
//----- MyS ------
bool timeReceived = false;
bool stateCom = false;
unsigned long lastUpdate=0, lastRequest=0 , lastmillis = 0;
unsigned long newTime = 0, oldTime = 0, ComTime = 6000;
//---------------- SETUP ----------------------------
void setup() {
//--- OLED ----
#if RST_PIN >= 0
oled.begin(&Adafruit128x32, I2C_ADDRESS, RST_PIN);
#else // RST_PIN >= 0
oled.begin(&Adafruit128x32, I2C_ADDRESS);
#endif // RST_PIN >= 0
oled.setFont(Adafruit5x7); /*font Oled*/
// oled.setFont(font8x8); //bien
// oled.setFont(Verdana12); //grand
// oled.setFont(fixed_bold10x15); //tres grand
// oled.setFont(Arial_bold_14); //grand sympa
oled.clear();
}
//--------------MySensors-------------
void presentation() {
sendSketchInfo("Clock", "2.0");
}
//------------------ LOOP -----------------------
void loop() {
// ---- MyS time --------
unsigned long now = millis();
if (now-lastRequest > (ComTime)) {
timeReceived = false;
requestTime(receiveTime); // Request time from controller.
lastRequest = now;
}
//----- Tempo Display Oled ----------
if (now-lastUpdate > 10000) { //10secondes
lastUpdate = now;
// Serial.print(" test lastmillis------------ display : ");
// Serial.println(timeReceived);
updateDisplay();
lastmillis = millis();
//----- Stat Com ---
if (timeReceived == 1) { //En Com Controller stateCom
ComTime = 480UL*1000UL; // 480=8 minutes cycles for Control presence controller
}
else { // Erreur Com Controller
stateCom = false;
ComTime = 60UL*1000UL; // secondes for attempted reconnection to the controller
// Serial.println(" ----*** Erreur Com Controller *** ---- ");
}
}
} //---Loop
// -------------------- MyS --------------------------------
void receiveTime(unsigned long controllerTime) {
if (receiveTime) stateCom = true ; else stateCom = false;
newTime = controllerTime;
timeReceived = true;
setTime(controllerTime); // apl pour TimeLib.h
}
//------------Gestion de l'affichage OLED---------------
void updateDisplay() {
oled.set1X(); //ligne Message
oled.setCursor(2, 0);
printStatDay () ; // affiche jour de la semaine/poster day of the week
//oled.print(day());
oled.set2X(); //ligne Heures
oled.setCursor(18,1);
oled.print(hour());
printDigits(minute());
printDigits(second());
oled.set1X(); // ligne jour mois Année / day month year
oled.setCursor(35,3);
oled.print(day());
printDigitsDay(month());
printDigitsDay(year());
}
//-------- Day displaying-------
void printDigitsDay(int digitday) { //function for Day displaying "0" and separator "/" for day/month/year values
oled.print("/");
if(digitday < 10)
oled.print('0');
oled.print(digitday);
}
//-------- Time displaying-------
void printDigits(int digits) { //function for Time displaying "0" and separator ":" for hour:minute:sec values
oled.print(":");
if(digits < 10)
oled.print('0');
oled.print(digits);
}
//------ conversion date en texte (fonction weekday) et statu Com Controller -----------
void printStatDay () { //function for display Day texte
oled.invertDisplay(!(stateCom)); // inverse N/B Oled sur erreur Com
if(stateCom == true) { oled.print("com "); } //com okai
if(stateCom == false){ oled.print("Error"); } //com Error
// oled.print(stateCom);
oled.print(" ");
if(weekday() == 1) { oled.print("dimanche"); } //Sunday
if(weekday() == 2) { oled.print("lundi"); } //Monday
if(weekday() == 3) { oled.print("mardi"); } //Tuesday
if(weekday() == 4) { oled.print("mercredi"); } //Wednesday
if(weekday() == 5) { oled.print("jeudi"); } //Thursday
if(weekday() == 6) { oled.print("vendredi"); } //Friday
if(weekday() == 7) { oled.print("samedi"); } //Saturday
oled.print(" ");
oled.print(day());
}
//-------------------FIN PGM --------------------------
//------------------- INFO -------------------
why open a new post, there is still some space here
final sketch and functional with MyController
/*
* DESCRIPTION : 4 inputs and 4 outputs on i2C bus with a PCF8574
*
* LIBRAIRIES:
* - Rob Tillaart pour PCF8574 https://github.com/RobTillaart/Arduino/tree/master/libraries/PCF8574
* - MySensors / Arduino Uno https://github.com/mysensors/MySensors
*
* ELEMENTS:
* - Expander PCF8574 avec module Metasys JC / 4di 4do - 0X03D i2c adress
*
* MODIFICATION:
* -x- RAS : Fonctionnelle
* -o-
* -o-
*
* (36%) de l'espace de stockage de programmes
*/
//----------- 9 Mai 2022 ---------------- PCF8574 -4DI-4DO / MyS RS485 et MyC -----------------//
//------------------- MyS ---------------------------------
//#define MY_DEBUG /*Enable debug prints to serial monitor*/
//#define MY_DEBUG_OTA_DISABLE_ECHO //testing
#define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo de mis en Com (millisecondes) à placer avant Mysensors.h*/
#define MY_NODE_ID 40 /*Node en ID static*/
/* ----- Module TTL-RS485 ----*/
#define MY_RS485 /*Apl du transport RS485 (protocol?)*/
#define MY_RS485_DE_PIN 10 /*Cmd DE pin*/
#define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/
#define MY_REPEATER_FEATURE /*Activer fonctionnalité de répéteur du nœud*/
#include <MySensors.h>
//---------------- PCF -------------------------------
#include "PCF8574.h"
PCF8574 PCF27a (0x3D); // adjust addresses i2c pcf8574
// ------ objet ------
#define CHILD_ID_B0 0 /*Id IN - bp */
#define CHILD_ID_B1 1
#define CHILD_ID_B2 2
#define CHILD_ID_B3 3
#define CHILD_ID_R4 4 /*Id OUT - relay */
#define CHILD_ID_R5 5
#define CHILD_ID_R6 6
#define CHILD_ID_R7 7
#define RELAY_ON 0 // 1 valeur
#define RELAY_OFF 1 // 0 invers
//---------- MyS -------------
MyMessage msg0(CHILD_ID_B0,V_TRIPPED); /*Boton*/
MyMessage msg1(CHILD_ID_B1,V_TRIPPED);
MyMessage msg2(CHILD_ID_B2,V_TRIPPED);
MyMessage msg3(CHILD_ID_B3,V_TRIPPED);
MyMessage msg4(CHILD_ID_R4,V_STATUS); /*Relay*/
MyMessage msg5(CHILD_ID_R5,V_STATUS);
MyMessage msg6(CHILD_ID_R6,V_STATUS);
MyMessage msg7(CHILD_ID_R7,V_STATUS);
bool info; // pour info GW sur MyC
bool state = false; // output
// bool state4 = false; bool state5 = false; bool state6 = false; bool state7 = false;
int oldValue0=-1; int oldValue1=-1; int oldValue2=-1; int oldValue3=-1; // Input
//---------------- SETUP -------------------------
void setup() {
// Serial.begin(115200); // debug
//--------- testing IsConnected i2c PCfx ------------
Serial.println(__FILE__);
Serial.print("PCF8574_LIB_VERSION:\t");
Serial.println(PCF8574_LIB_VERSION);
if (!PCF27a.begin()) {
Serial.println("could not initialize...");
}
if (!PCF27a.isConnected()) {
Serial.println("=> not connected");
}
else {
Serial.println("=> connected!!");
}
// ---- info send to gateway ----
send(msg0.set(info)); send(msg1.set(info)); //input
wait(200);
send(msg2.set(info)); send(msg3.set(info)); //input
wait(200); //delays for frames, depending on system load and bus type (wireless or wired)
send(msg4.set(info)); send(msg5.set(info)); //output
wait(200);
send(msg6.set(info)); send(msg7.set(info)); //output
}
//----------------- MyS ----------------------------
void presentation() {
sendSketchInfo("PCF8574 x4in/out - node40", "2.0"); /*info version sketch*/
/*Mysenors Enregistre Child sur la Gw*/
present(CHILD_ID_B0, S_DOOR, "boton0"); /*Boton*/
present(CHILD_ID_B1, S_DOOR, "boton1");
wait(200);
present(CHILD_ID_B2, S_DOOR, "boton2");
present(CHILD_ID_B3, S_DOOR, "boton3");
wait(200); //delays for frames, depending on system load and bus type (wireless or wired)
present(CHILD_ID_R4, S_BINARY, "relay4"); /*Relay*/
present(CHILD_ID_R5, S_BINARY, "relay5");
wait(200);
present(CHILD_ID_R6, S_BINARY, "relay6");
present(CHILD_ID_R7, S_BINARY, "relay7");
wait(200);
// metric = getControllerConfig().isMetric;
}
//----------------- LOOP ----------------------------
void loop() {
//----------- MyS input -------------------------------
int value0 = PCF27a.read(0);
if (value0 != oldValue0) {
send(msg0.set(value0==HIGH ? 1 : 0)); //Send new value
oldValue0 = value0;
}
int value1 = PCF27a.read(1);
if (value1 != oldValue1) {
send(msg1.set(value1==HIGH ? 1 : 0));
oldValue1 = value1;
}
int value2 = PCF27a.read(2);
if (value2 != oldValue2) {
send(msg2.set(value2==HIGH ? 1 : 0));
oldValue2 = value2;
}
int value3 = PCF27a.read(3);
if (value3 != oldValue3) {
send(msg3.set(value3==HIGH ? 1 : 0));
oldValue3 = value3;
}
}
//----------- MyS out -------------------------------
void receive(const MyMessage &message) {
if (message.getType()==V_STATUS) {
switch (message.sensor) {
case 4:
state= message.getBool();
PCF27a.write(4, state?RELAY_ON:RELAY_OFF);
break;
case 5:
state = message.getBool();
PCF27a.write(5, state?RELAY_ON:RELAY_OFF);
break;
case 6:
state = message.getBool();
PCF27a.write(6, state?RELAY_ON:RELAY_OFF);
break;
case 7:
state = message.getBool();
PCF27a.write(7, state?RELAY_ON:RELAY_OFF);
break;
}
}
}
//------------------------------ End pgm -------------------------------------
here is a small truth table for the state of the input/output and the values to give to MyController
#define RELAY_ON 0 // 1 reversal of values
#define RELAY_OFF 1 // 0
now only the MyS states to be sent to MyC to find.
I stop my dialogue
Hello
a request for information.
What value should be given to avoid a difference in the on/off states between the visualization on the controller and the reality on the LEDs of the Expander module?
on which feet to start ????
Another question, how to have the synchronicity of the state of the physical outputs (relays/led) and the view on MyC ???
with this version of the sketch the state of the outputs is well to go back to the controller after reboot of the Node
void receive(const MyMessage &message) {
if (message.getType()==V_STATUS) {
// Change relay state
state = (bool)message.getInt();
PCF27a.write(4, state?RELAY_ON:RELAY_OFF);
send(msg4.set(state?RELAY_ON:RELAY_OFF))
but now with this version, the reality is false
(an augmented reality )
void receive(const MyMessage &message) {
if (message.getType()==V_STATUS) {
switch (message.sensor) {
case 4:
state = message.getBool();
PCF27a.write(4, state?RELAY_ON:RELAY_OFF);
break;
the function
// send(msg4.set(PCF27a.read(4)));
is removed and you can't see how to add it
merci
/*
* Test PCF8574 avec module Metasys JC / 4di 4do - 0X03D i2c adress
*
* DESCRIPTION : Exemple pour lire 4 entrée et contrôler 4 Relais
* avec un PCF8574 (la commande et par les 4 entrée)
*
* LIBRAIRIES:
* - Rob Tillaart pour PCF8574 https://github.com/RobTillaart/Arduino/tree/master/libraries/PCF8574
*
* ELEMENTS:
* Do : ? - Digital output / Relay
*
* Modification:
* -x-
* -o-
* -o-
*
* (14%) de l'espace de stockage de programmes
*/
//-----------2022---------------- PCF8574 / 4DI-4DO - MyS et MyC -----------------//
//--------------- MyS ---------------------------------
//#define MY_DEBUG /*Enable debug prints to serial monitor*/
//#define MY_DEBUG_OTA_DISABLE_ECHO //testing
#define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo de mis en Com (millisecondes) à placer avant Mysensors.h*/
#define MY_NODE_ID 40 /*Node en ID static*/
/* ----- Module TTL-RS485 ----*/
#define MY_RS485 /*Apl du transport RS485 (protocol?)*/
#define MY_RS485_DE_PIN 2 /*Cmd DE pin*/
#define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/
#define MY_REPEATER_FEATURE /*Activer fonctionnalité de répéteur du nœud*/
#include <MySensors.h>
//---------------- PCF -------------------------------
#include "PCF8574.h"
PCF8574 PCF27a (0x3D); // adjust addresses i2c pcf8574
// ------ objet ------
#define CHILD_ID_B0 0 /*Id IN - bp */
#define CHILD_ID_R4 4 /*Id OUT - relay */
#define RELAY_ON 1
#define RELAY_OFF 0
int oldValue0=-1; // input bp
//---------- MyS -------------
MyMessage msg0(CHILD_ID_B0,V_TRIPPED); /*Boton*/
MyMessage msg4(CHILD_ID_R4,V_STATUS); /*Relay*/
bool info; // pour info GW sur MyC
bool state = false;
//---------------- SETUP -------------------------
void setup() {
//Serial.begin(115200);
//--------- testing IsConnected i2c PCfx ------------
Serial.println(__FILE__);
Serial.print("PCF8574_LIB_VERSION:\t");
Serial.println(PCF8574_LIB_VERSION);
if (!PCF27a.begin()) {
Serial.println("could not initialize...");
}
if (!PCF27a.isConnected()) {
Serial.println("=> not connected");
}
else {
Serial.println("=> connected!!");
}
PCF27a.begin(0xFF); // turn off all Relays ????
// ---- info send to gateway ----
send(msg0.set(info));
send(msg4.set(info));
}
//----------------- MyS ----------------------------
void presentation() {
sendSketchInfo("DiDo node 40", "2.0"); /*info version sketch à la passerelle*/
/*Mysenors Enregistre Child sur la Gw*/
present(CHILD_ID_B0, S_DOOR, "boton"); /*Boton*/
present(CHILD_ID_R4, S_BINARY, "relay"); /*Relay*/
/* requetes/demandes à un noeud ou GW une variable*/
request(CHILD_ID_B0, V_STATUS); /*Boton*/
request(CHILD_ID_R4, V_STATUS); /*Relay*/
// metric = getControllerConfig().isMetric;
}
//----------------- LOOP ----------------------------
void loop() {
/* ------ MyS input -----------------------*/
int value0 = PCF27a.read(0);
if (value0 != oldValue0) {
send(msg0.set(value0==HIGH ? 1 : 0)); // Envoyer la nouvelle valeur
oldValue0 = value0;
}
}
//--------- MyS out ----------------------------
void receive(const MyMessage &message) {
if (message.getType()==V_STATUS) {
// Change relay state
state = (bool)message.getInt();
PCF27a.write(4, state?RELAY_ON:RELAY_OFF);
send(msg4.set(state?RELAY_ON:RELAY_OFF));
}
}
//------------------------------ End pgm -------------------------------------
Operation Expander success
I show you two sketches, still based on Rob Tillaart library.
the 1st one is a basic version without MySensors
(to understand how the library works)
an Input (a shunt) controls an Output.
4 inputs 4 outputs
the 2nd one is with MySensors, everything goes up well on MyController, and the 1st time (I am surprised )
a request, a hand for the 2nd for a "clean" touch up of the code (or errors to remove ?? )
Yes code readable for beginners, simple function.
after cella another video
Thanks and good night
/*
* Test PCF8574 avec module Metasys JC / 4di 4do - 0X03D i2c adress
*
* DESCRIPTION : Exemple pour lire 4 entrée et contrôler 4 Relais
* avec un PCF8574 (la commande et par les 4 entrée)
*
* LIBRAIRIES:
* - Rob Tillaart pour PCF8574 https://github.com/RobTillaart/Arduino/tree/master/libraries/PCF8574
*
* ELEMENTS:
* Do : ? - Digital output / Relay
*
* Modification:
* -x-
* -o-
* -o-
*
*
*/
//-----------2022---------------- PCF8574 / 4DI-4DO - JC -----------------//
#include "PCF8574.h"
PCF8574 PCF27a (0x3D);
//---------------- SETUP -------------------------
void setup() {
Serial.begin(115200);
//--------- testing IsConnected i2c PCfx ------------
Serial.println(__FILE__);
Serial.print("PCF8574_LIB_VERSION:\t");
Serial.println(PCF8574_LIB_VERSION);
if (!PCF27a.begin()) {
Serial.println("could not initialize...");
}
if (!PCF27a.isConnected()) {
Serial.println("=> not connected");
}
else {
Serial.println("=> connected!!");
}
}
//----------------- LOOP ----------------------------
void loop() {
if (PCF27a.read(0) == LOW) do4High(); else PCF27a.write(4, HIGH) ;
if (PCF27a.read(1) == LOW) do5High(); else PCF27a.write(5, HIGH) ;
if (PCF27a.read(2) == LOW) do6High(); else PCF27a.write(6, HIGH) ;
if (PCF27a.read(3) == LOW) do7High(); else PCF27a.write(7, HIGH) ;
}
// ------- 4x Relay ON ----------
void do4High() {
PCF27a.write(4, LOW);
}
void do5High() {
PCF27a.write(5, LOW);
}
void do6High() {
PCF27a.write(6, LOW);
}
void do7High() {
PCF27a.write(7, LOW);
}
//------------------------------ End pgm -------------------------------------
in this sketch there is only the Mysensors library to call, to test
I just have to finalize my sketch and it to MyController
/************************************************************************************
Using an Arduino Uno or an ESP8266 on NodeMCU to control buttons
and relays through a PCF8574 GPIO expander.
Requires the PCF8574 library
https://github.com/RobTillaart/Arduino/tree/master/libraries/PCF8574
If using Uno, comment out #define intPin D4
If using ESP8266, comment out #define intPin 2
GPIO expander pinout: 0..3 = button input 0..3
4..7 = relay output 0..3
Each button controls a corresponding relay
eg. button 0 controls relay 0
Button functions: button 0 and 1 toggle relay 0 and 1 on each press
button 2 and 3 directly control relay 2 and 3 in "realtime"
Gadget Reboot
*************************************************************************************/
/*
* DESCRIPTION : Arduino UNO et JC-PCF8574 pour 4 Input et 4 Relay
* pour MySensors RS485
*
* Libraries: PCF8574 de Rob Tillaart
*
* Modif/Afaire:
* -o-
* -x-
* -o-
* (x%) de l'espace de stockage de programmes
*
*/
//----------- 2022 ------ PCF8574_RobTi_MyS_4io.ino ---------- test -----------------//
//--------------- MyS ---------------------------------
#define MY_DEBUG /*Enable debug prints to serial monitor*/
#define MY_DEBUG_OTA_DISABLE_ECHO //testing
#define MY_TRANSPORT_WAIT_READY_MS 3000
#define MY_NODE_ID 40 /*Node en ID static*/
#define MY_RADIO_RF24
#include <MySensors.h>
//---------------- PCF -------------------------------
#include <PCF8574.h>
#include <Wire.h>
PCF8574 pcf8574(0x3D);
#define intPin 3 // interrupt input Uno
volatile bool buttonPressed = false; // button interrupt flag
byte buttonReg; // button read register
//----------------- SETUP -------------------------
void setup() {
//initialize PCF8574 with an interrupt pin and set all outputs to '1' (Relays off)
Wire.begin();
pinMode(intPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(intPin), buttonISR, FALLING);
pcf8574.begin(0xFF); // turn off all Relays
}
//----------------- LOOP ----------------------------
void loop() {
// if a button press was detected via interrupt, check if the button press
// occurred on one of the "toggle" control buttons and toggle the relay if so
if (buttonPressed) {
delay(50); // crude debounce
buttonReg = pcf8574.read8();
if (!bitRead(buttonReg, 0)) { //toggle a relay if button pressed
pcf8574.toggle(4);
}
if (!bitRead(buttonReg, 1)) { //toggle a relay if button pressed
pcf8574.toggle(5);
}
}
buttonPressed = false; // clear interrupt flag
// manually poll last two buttons and set relays to match button on/off realtime state
// method 1: read all buttons and choose the desired button from the read register
// buttonReg = pcf8574.read8();
// pcf8574.write(6, bitRead(buttonReg, 2));
// method 2: directly read just one button and directly set the target relay
pcf8574.write(7, pcf8574.read(3));
pcf8574.write(6, pcf8574.read(2));
}
//---- interrupt service routine ------------
void buttonISR() {
buttonPressed = true;
}
//------------------------------ End pgm -------------------------------------
Hello
a little more information on the PCF8574 based material
obsolete industrial equipment recovered in a trash can.
system building controller from "Johnson Control" the "metasys" game
https://cgproducts.johnsoncontrols.com/MET_PDF/6364040.PDF
why the choice of this hardware base ?
The Opto coupler !
if not for the Arduino sketch, and its functionning with the PCF8574 library from RobT it's functional
as soon as I activate
#define MY_TRANSPORT_WAIT_READY_MS 3000
it works, why it works
Thank you jkandasa for your curiosity, yes the fact that I dive back into it there was like a spark inter neuronal
Thanks
well, here we are, we think we are alone in the world, but no
thank you skywatch
they is or my sketch that I answer to jkandasa
Hello jkandasa
I will have to find my skecth in my sketch box
but in the meantime I have a problem to solve, very serious
I can't connect to the MyController forum.
it happened after I cleared my browser cache
I have recreated a new password but nothing, I don't have the hands.
This sentence is thrown in my face:
Login failed
We cannot connect you, probably because your session has expired. Please try again.
even creating a new account is impossible
thank you
Hello
good news, the libraries for PCF8574 are not compatible with MySensors, one less thing to manage.
I have been testing for a week the different version of library found on the web, it works well, but when I insert the bases of the sketch for MySensors the i2C communication is blocked, and the PCF8574 remains the four iron in the air.
even with the super https://github.com/RobTillaart/PCF8574
I've been looking for a practical expander and MySensors on the web, but nothing.
So everything is normal???
yes it's not easy, the loss of package is a difficult thing to
to counter, but not entirely.
and the multiple layers of a computer system do not help
some philosophy on collision avoidance
https://arduino.stackexchange.com/questions/24523/rs485-multimaster-communication-with-collision-avoidance
don't mix the Protocol (data encapsulation)
and the physical support (voltage frequency impendance / star or serial bus)
the ModBus protocol on a RS485 support
https://www.electroniclinic.com/arduino-modbus-rs485-arduino-rs485-master-and-slave/
a different explanation https://www.codrey.com/learn/rs-485-arduino-quick-primer/
for information
https://github.com/sonyarouje/Arduino_HardwareSerial_RS485
But the best solution (reliability and especially lightness of the sketch) is the CAN bus
I may have said some stupid things
Translated with www.DeepL.com/Translator (free version)
Yes MySensors must continue, and it continues to live
it's a system open to all possible modifications.
an economical system, not obsolete in 1 years, not polluting Hertzian and reliable with the implementation of field bus (Rs485 - CAN)
why such a madness of technology to tell me that in my living room it is 20°C or that my front door is open?
a web server for a temperature sensor is nonsense.
Yes to the Minimalist System
Faithful reader of Elektor since the number 1, I see the technological progression
which leads us to our loss.
IoT objects on LoRaWan still a polluting thing*.
ByBye
Translated with www.DeepL.com/Translator (free version)
can be the good solution to put everything back to MyController
without doing anything
bool info;
Void setup {......
//info send to gateway
send(msg.set(info));
send(msgx.set(info)); //pour d'autres
...}
to be seen later
exit status 1 : 'value' was not declared in this scope
but why in the setup ?
you have to put it in Loop () ?
//-----------Mars.2022------- Node 32 --------- MySensors DI DO MyController -----------------//
// #define MY_DEBUG /*Enable debug prints to serial monitor*/
// #define MY_DEBUG_OTA_DISABLE_ECHO //envoyer des messages sans demander à la destination de renvoyer le message
// Mysensors advanced settings
// #define MY_TRANSPORT_WAIT_READY_MS 3000 /*Tempo d'attente de mis en Com, des millisecondes - à placer avant Mysensors.h*/
// #define MY_SPLASH_SCREEN_DISABLED /*désactive écran de démarrage MySensors (économie 120oct. en flash)*/
#define MY_NODE_ID 32 /*Node en ID static*/
/* ----- Module TTL-RS485 ----*/
#define MY_RS485 /*Apl du transport RS485 (protocol?)*/
#define MY_RS485_DE_PIN 2 /*Cmd DE pin*/
#define MY_RS485_BAUD_RATE 9600 /*Set RS485 baud rate to use*/
#define MY_REPEATER_FEATURE /*Activer fonctionnalité de répéteur du nœud*/
#include <MySensors.h>
#include <Bounce2.h>
// ------ objet ------
#define RELAY_PIN 7 /*Pin Relay-DO*/
#define BBUTTON_PIN 6 /*Pin boton-DI*/
#define CHILD_ID_R 3 /*Id du Relay*/
#define CHILD_ID_B 4 /*Id du bouton poussoir*/
#define RELAY_ON 1
#define RELAY_OFF 0
//----- Instancier objet Bounce ------
Bounce debouncer = Bounce();
int oldValue=0;
bool state;
// ------ Mysensors -------
MyMessage msg(CHILD_ID_R,V_STATUS); /*Relay*/
MyMessage msg1(CHILD_ID_B,V_TRIPPED); /*Boton*/
void setup() {
pinMode (RELAY_PIN,OUTPUT); /*config pin relay*/
digitalWrite(RELAY_PIN, RELAY_OFF); /*désactive Relay au démarrage*/
pinMode(BBUTTON_PIN,INPUT_PULLUP) ; /*Configure Pin en input et Active pull-up interne*/
debouncer.attach(BBUTTON_PIN); /*configurez l'instance Bounce*/
debouncer.interval(5); /*interval in ms*/
// send(msg.set(value==HIGH ? 1 : 0)); /*Relay
}
void presentation() {
sendSketchInfo("DiDo node 32", "2.0"); /*info version sketch à la passerelle*/
/*Mysenors Enregistre Child and Gw*/
present(CHILD_ID_R, S_BINARY); /*Relay*/
present(CHILD_ID_B, S_DOOR); /*Boton*/
/* requetes/demandes à un noeud ou GW une variable*/
request(CHILD_ID_R, V_STATUS); /*Relay*/
request(CHILD_ID_B, V_STATUS); /*Boton*/
}
void loop() {
/*Vérifie un changement d'etat sur les entrées numérique et envoye la nouvelle valeur*/
debouncer.update(); /*Update the Bounce instances*/
int value = debouncer.read(); /*Get the updated value*/
/*Relay*/
// if (valueR != oldValueR) {
// send(msg.set(valueR==HIGH ? 1 : 0)); /*Envoyer la nouvelle valeur*/
// Serial.println ("Changement d'etat bouton A");
// oldValueR = valueR;
// }
/*bouton*/
if (value != oldValue) {
send(msg1.set(value==HIGH ? 1 : 0)); // Envoyer la nouvelle valeur
Serial.println ("Changement d'etat bouton ");
oldValue = value;
}
}
void receive(const MyMessage &message) {
// attente qu'un seul type de message du contrôleur , vérifier.
if (message.isAck()) {
Serial.println("Ceci est un accusé de réception de la passerelle");
}
if (message.type == V_STATUS) //V_STATUS ancien V_LIGHT
{
state = message.getBool ();
digitalWrite(RELAY_PIN, state?RELAY_ON:RELAY_OFF); // Changer l'état du relais
//if (message.getType()==V_STATUS) {
// Change relay state
// digitalWrite(message.getSensor() - RELAY_PIN, message.getBool()?RELAY_ON:RELAY_OFF);
}
}
// -------------------- END PGM ---------------------------
Hello jkandasa
I spent the day on the Mysensors website copying/translating some parts of the "serial_api_20" doc
(I have no more eyes )
yes I will add it soon
send(msg.set(value==HIGH ? 1 : 0)); // Relay
you mas understood, I try to write well the code of the sckech
so that MyCrontroller goes up cleanly the sensors
Merci