Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. OldSurferDude
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by OldSurferDude

    • RE: LGT8F328P and MySensors

      @paede said in LGT8F328P and MySensors:

      LGT8F328P

      There are some instructions on this page? Here's another link that might be helpful.

      I know nothing about this device other than the google search I just did on. Some red flags went up for me. The use of software for the third party board, and a newbie extoling its virtues. (astroturfing)

      Even if you get it running, it may not work with MySensors. I bought three official Nano Every's with your same hopes and expectations. It claimed to be a direct replacement/upgrade. First, the MySensors nRF24 software did not work. Then I was unable to find a reliable way to put the Every into deep sleep.

      I've had pretty good luck with the Nano clones on AliExpress. I'd recommend getting the RF Nano because the radio is built in. Before I put one into production, I spray it with electrical lacquer to prevent corrosion. That said, as with everything else you get on AliExpress, caveat emptor.

      It will be appreciated if you get it working and present the details here as to how you did it.

      -OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: RS485 transmit errors

      @sebastieng Thanks for letting us and future readers know.

      -OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Sketch Names in Home Assistant - Resolved

      @nagelc I find that naming is a personal thing, though it should be consistent. For example, I had 9 devices, one of which was primary, and a controller. they were named, Rudolph, Dasher, Dancer, Prancer, Vixen, Comet, Cupid, Donner, Blitzen, and the controller, Reins.

      While there is quite a discussion, names are what works for you. If your design is for someone else, then names that easily documented, while descriptive, are appropriate.

      Reminds me of a joke. This woman had 13 children, 6 boys and 7 girls. All the boys' name were Bob, and the girls, Jill. When asked, "Why?", she responded, "At dinner time I only have to call two names." "But what if you want a specific one?" "Oh, then I call them by their last name."

      If you give careful thought to your naming system, it will be easier for you to remember. Otherwise you have to review someone else's naming system regularly.

      -OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Imitating a LoRaWAN(R) with ESP8266/ESP32 and MySensors

      @mfalkvidd Yes, I understand that 253 is the software limit. I was wondering about the hardware limit.

      For example, my Asus router has a software limit of 253 devices. But when I get 20-25 WiFi devices trying to connect, the network goes haywire. (pun intended 😉 ) I am quite convinced that this is a hardware limitation of the router because the router has to carry some information about each connection.

      If the gateway is dumb, that is, carries no information about any connection, then it could truly have 253 connections. After a bit of contemplation, I realize that the name, gateway, implies this.

      If that is the case, it is good news for the DiY'er in that this very inexpensive and cheap hardware could stand in for a LoRaWAN, again, with a number of compromises.

      posted in Development
      OldSurferDude
      OldSurferDude
    • Imitating a LoRaWAN(R) with ESP8266/ESP32 and MySensors

      Re: Gateways

      Re: Gateways

      I got interested in LoRaWAN(R). It actually looks much like MySensors, with long range radios. In fact, MySensors supports the rfm95 radio that is identical (?) to the LoRa radio.

      So I built a MySensors Gateway with an rfm95 radio running on an ESP-12F (Arduino board Generic ESP8266 Module) and a MySensors relay node running on an ESP32 WR-32 Development Board (Arduino board DOIT ESP32 DEVKIT V1). I included Over-the-Air (OTA) code, which is quite handy when it works. I was pretty impressed with a range of 25m through five walls...the WiFi didn't go that far!

      Here's the challenge, though. The ESP-12F does not have a lot of storage. Every "node" connecting to it will take a bit of that. How many nodes can attach to this gateway?

      I don't think a MySensors rfm95 sensor network could compete with a LoRaWan(R) network on specs. But when a LoRa humidity/temperature sensor goes for € 44, I think a DiY'er could justify a few compromises.

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: HW-488 infrared sensor not detecting properly

      @jaydenlord Probably you do. If you leave the EN floating, electrical noise could cause it to enable or disable randomly.

      Some enable pin require a HIGH, some LOW. Connect it to VCC to see if it works more consistently. If it doesn't detect, connect it to GND.

      If one of these works, then the part wasn't designed to be in a default state of enable.

      Let us know your results (I found this video

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Flame Sensor Not Triggering Setup

      You write "...clicking is heard..." Is that a single click or a click click click ...?

      After getting the LOW signal, wait a period of time and if it's still low, send the message that there is a flame. Likewise for a HIGH signal.

      Perhaps instead of a relay, an opto-isolator?

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Windows GUI/Controller for MySensors

      @emre299 alas, this cool project seems to be abandoned.

      posted in Controllers
      OldSurferDude
      OldSurferDude
    • RE: Pjon Script

      @sindrome73 said in Pjon Script:

      Pjon Protocol

      The only way I see this working is that the remote device (non-gateway sensor) sends the data using the PJON protocol over whatever medium. The remote device would not use any MySensors code.

      On the gateway, a "sensor" would be created that would receive the data using the PJON protocol over that medium. Once the data is received, it would be "sent" to the gateway portion of the code that is running on the gateway.

      Thus, for every remote sensor there would have to be a "sensor" on the gateway. Sort of defeats the purpose of a gateway.

      It would be nice if MySensors were media independent and PJON would be a good candidate. Alas, I don't believe there is sufficient support for MySensors these days to create that environment.

      As far as someone creating these scripts, I would advise you do a deep dive into PJON. The first part would be to create the POJON "Hello World" pair. Once you have this working, then you could incorporate it into your MySensors gateway.

      Let us know how it works out.

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Some questions on how gateway works

      @Homer That's really good to hear!

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Keen to build again

      @Homer I suspect the lack of interest is because there isn't much in the way of support anymore. Worse yet, I just (12h56PDT, 8 Aug 25) tried to go to the home page and it was not available. @mfalkvidd is very knowledgeable and, like me, shows up from time to time.

      I think MySensors is the best "frugal tech". You can build a plethora of sensors for under USD$5 (plus housing).

      I like tasmotized ESP8266, too, but that uses WiFi. These are automatically configured by Home Assistant (with the Tasmota integration). Most home routers max out on WiFi connections at 20-25, though. ESP devices can be programmed with c++ using the Arduino IDE. When configured, they can be OTA (Over-The-Air) reprogrammable.

      I am under the impression that an ESP device can be a gateway. This would require the device to have a radio (nRF24?) so that MySensors sensors can connect through it.

      But, the process to configure the gateway is on the homepage of MySensors. I hope it comes back 😮

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Code Garage to the rescue.

      @CodeGarage I am getting the message that www.mysensors.org is not responding (13h22 PDT 8 Aug 25) Is MySensors officially dead?

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: MySensors Gateway Controller Failed to ACK I_FIND_PARENT Request from Node

      @Eme

      Thank you for coming back to report how you solved your problem! Your comments will help other people.

      I am a big fan of Frugal Tech and I think MySensors is great for that.

      Alas, MySensors is not well supported anymore. Right now I'm having problems linking to the home page 😞 It's people like you and me that will keep MySensors going.

      Thanks for your help.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Some questions on how gateway works

      @homer You do have to put in the MQTT parameters, such as, MQTT broker IP. The logic of your sensors and how you send the data remains the same.

      In Home Assistant you have to have the MQTT integration and the MySensors integration.

      1. Set up your MQTT broker
      2. install the MQTT integration
      3. install the MySensors integration (I always forget which goes where, MySensorsIn and MySensorsOut)
      4. create and configure your MySensors MQTT gateway
      5. add the MQTT code to your sensors

      Once you turn on your sensors, they should appear in Home Assistant as devices.

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: AI: What is the future of Wikis and Forums?

      The problem with AI is that it relies on existing data. Without us humans feeding it, it will only find existing solutions, not new solutions. Fortunately, there are a lot of existing solutions.

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Keen to build again

      I can't speak to the subtle differences between 2.3.2 and 2.3.1. I would advise on proceeding, whether upgrading or not.

      A gateway to Home Assistant can run on an Arduino Nano with an nRF24 radio (or RF Nano found on AliExpress). This gateway can connect to Home Assistant via the serial port of the computer running Home Assistant.

      I see that there is still a Vera integration on Home Assistant. You could probably pick up where you left off.

      Yes, MySensors popularity has waned, but there are a few of us die-hards that check in from time to time. Please continue to share your experience.

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: IP phone and beacon

      @ben999 said in IP phone and beacon:

      digital signal, IP

      I don't really know what a beacon of which you write, is.

      If the signal is Internet Protocol (IP) then you may be able to use Wire Shark to help you reverse engineer the signal. Maybe the information is the in the public domain and it will take a lot of research.

      Good luck

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Cannot find the board: "Arduino Mini pro MYSBootloader"

      I've never used the MYSBootloader firmware, but I am intrigued by being able to upload code Over the Air (OTA).

      My brief research came up with this link to MySensors Forum thread: MYSBootloader 1.3 pre-release & MYSController 1.0.0beta. It may be of some help to you.

      -OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: Hey I am new here

      Check out My Projects to see what can be done. Then decide what you want to do.

      Come back here for help

      -OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: gateway MQTT

      I don't have a good answer for you @mimaret 😞 When I get to the point where I'm getting strange error messages, I bite the bullet and start from ground zero. Fortunately, with the RPi you just need a new SD card.

      Start with a fresh copy of the Raspberry Pi OS. If you enable SSH (and WiFI) when you create the image, you can do everything headless (without keyboard-mouse-video) by running raspi-config via a remote terminal ( PuTTY ) If you enable VNC with raspi-config you can have access to the GUI.
      Double check your radio wiring.
      Don't have anything unnecessary plugged in.
      Carefully follow the instructions

      I've done this tedious process many times. My RPi's are 3B+ and Zero 2 W. Here's what I've encountered:

      • bad power supply
      • bad SD card
      • bad wiring
      • corrupt download
      • and, of course, more user errors than I care to think about!
      • I have not come across bad RPi ... no, not true! I had a Zero 2 W with a bad WiFi chip (common problem). Overcame that with a USB WiFi dongle.

      Good luck! Let us know what you discover.

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: CHATGPT My new best friend!

      @Tmaster I think it writes better code than a lot of code I've seen, and the documentation is a lot better. The latter, of course, is because most coders don't document. 😞

      some key elements:

      • good statement of work -- Purpose of the Code is key (did you write that? Good job!). This will guide the AI to write what you want.
      • descriptive variables
      • good documentation
      • code is independent of reading sensors up-to-down/down-to-up

      I spent a couple hours analyzing, researching and writing and re-writing this and all I can say is that the AI didn't catch is, as far as I can see, if your sensors are too far apart or your magnet is too weak, you could get false readings.

      You, being the author of AI directive, are responsible for for the code. The AI is just a tool.

      I started my coding with assembly language, though at that time we still had to enter the binary on some machines (set 16 switches, then press commit). ForTran and COBOL were the first real high level languages and subsequent languages, pascal, c, java, etc. were improvements. AI is a quantum step. It's still coding, but you have to learn how to talk to the AI to get what you want.

      Good project! Let us know how it turns out and if you had to tweak the code.

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: CHATGPT My new best friend!

      I agree with @fsgraz !

      @Tmaster Here's the challenge with AI, it doesn't know what you want. Also, it only knows what has been done. That said, most of what we do has already been done and it can infer what you want.

      Not knowing what the code does makes errant code difficult to debug. And debugging someone (something?) else's code is even more difficult. The upside of that is debugging errant code is that it is a great learning tool.

      A forum like this is a great way to share knowledge and you are sharing your great success with AI. I'm impressed and I'm going to try it. Key to this sharing is having a good command of the language one uses to communicate. One could use AI to formulate a succinct description of the code, too. (Note that some languages express some ideas better than other one's native language, thus using other languages is also a good communication technique.)

      Thanks for sharing and stimulation!

      ps, can you share the code that the AI generated?

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Raspberry Pi 5: invalid GPIO 9

      @igo As you may be aware, MySensors is not well supported these days. In fact, the support comes from people like you and me who still find value in MySensors.

      That said, search for a replacement for raspi-gpio. There may be a few. See if they work. It's important to the MySensors community that you report your success or failure to do so.

      I've done this sort of thing before and learned a lot from the experience. Let us know how it goes!

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Soil moisture sensor for house plants

      I think the comments you make are good. I do have a question about the removing the regulator. I assume you mean the 5V to 3.3V regulator.

      I connect to the 5V and I see lot of variation in moisture readings due to the variation in the output of the power supply (solar panel/stepdown). I have a calibration routine for that. The voltage can go as high as 4.2V, which I believe may be bad if I connect the power supply to 3.3V.

      Of course, this is not a concern if using two 1.5V batteries. With batteries, the moisture reading would be more consistent over a day. Lot of advantages there. I just don't like changing batteries and I really hate it when they leak. I have every reason to believe that my power supply will last 10 years and I am fortunate to live in a place with consistent sunshine 🙂 . Someone replicating my project will have to take this into consideration. My design easily accommodates a different power supply.

      And my power supply could be used in other projects.

      Resistive vs Capacitive sensor. I'm glad you report good results. This gives people options.

      Water moisture: I've had good experience with "spraying" the Arduino with clear electronic coating and sealing the enclosure with liquid tape.

      -OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Soil moisture sensor for house plants

      I did a soil moisture sensor for outdoors. It is powered from an 18650 battery charged from a small solar panel (1W).

      My device uses 6mA in standby. Can you provide a reference on achieving 10µA? Removing the power LED certainly will reduce power usage, though one loses the visual of power on when debugging.

      The sensor I use is capacitive, as opposed the resistive your using. I read somewhere that resistive probes corrode faster, but then, I've had problems with the devices I'm using because the electronics got wet (I think I've fixed that in this version).

      I have 4 units deployed. One solar panel is much less than 1W and doesn't provide enough power during a cloudy day. It comes and goes. Another has stopped communicating. and I have yet to determine its problem. (They're remote and I'm a lot of kilometers away from them.)

      I'd suggest you create a github page and fully document what you've done. My hope is that my documentation is adequate to the point that someone can build it with no help from me, even though I'd be glad to help.

      Good job!

      -OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Newbie: confused by the jargon, needing simple guidance...

      @Meldrew-s-mate Digital Communications is a pretty nebulous subject. Just to name the protocols is a daunting task.

      That said, I'd suggest limiting yourself to the application layer That is, what you can do by connecting to the host with a web page. You'd need to know the IP (internet protocol) address of the host. That would be in the the form of nnn.nnn.nnn.nnn. You'd open a browser and in the address field, enter https://nnn.nnn.nnn.nnn

      For example, your typical home router has and IP address of http://192.168.1.1 You open that in your browser and you are able to configure the router. You can determine the router's IP address by opening a command window. In Windows that is: <windows key> then type cmd <enter> (I don't speak Mac). This is called the command line (cli). Then execute the command ipconfig. You'll see default gateway: That is your router's IP address.

      When you write "how data is 'packaged' for transport" you're asking about very low level programming. This is something that is done in a library of a high level language (eg. c++). For most of what is done in home automation, even the high level language is already written for a significant portion of what you would do.

      But if this is what you want to learn, start with MQTT. Read the MQTT documentation. You won't understand it in the first read. But then install an MQTT broker on your computer (search, "Install MQTT broker"). You can use command line (cli) commands to publish (write) and subscribe (read) topics. Get MQTT Explorer (easy search) to observe what is going on in the broker. All of this you can do right now.

      Once you get a feel for that you could get a Raspberry Pi. You'll have to install the OS (operating system), which is well documented. Then search for "write to an MQTT topic using Raspberry Pi"

      This "data from different transducers (sensors) share a common language." is the home automation controller (eg. Node-Red). Right now home automation is still nerd-land, but it is on the cusp of going mainstream. This means a lot of trial-and-error.

      Do your experimenting on a computer other than the one you use regularly. A Raspberry Pi works well for this. Or, back up your computer; you're going to crash it.

      -OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: New Setup for Home Environment Monitoring – Using NRF24L01+, Arduino Pro Mini, and BME280

      @nagelc said in New Setup for Home Environment Monitoring – Using NRF24L01+, Arduino Pro Mini, and BME280:

      bme280

      I read somewhere that the temperature sensor on the BME280 is sort of an afterthought. I did a few experiments comparing them to the DHT11/12/22 and found them only a little better. (Take this with a grain of salt, maybe you'll want to do you're own experiments.) I did do a lot of experiments with the DHT's and they really suck. +/-2°C Which turns out to mean +/-2°C offset (component variation) and +/-2°C measurement: +/-4°C from what the temperature actually is. My experience, yours may be better.

      Please post your experience with OTA. I haven't tried it on Arduino's but it's awesome on ESP8266. I hesitate with Arduino's because I had some erratic behaviour running Arduino's when pushing the memory limit.

      I, too, use the MQTT data transport to Home Assistant (HA) and I find that excellent. Getting data from HA is a bit tricky, but do-able. I have a flow meter and use HA to store the last read; meaning, if there is a power failure, HA sends the last read on Arduino boot. I don't use the EEPROM because that has a spec of 100,000 writes which the meter would do in about a year, thus, necessitating a new Arduino.

      I truly appreciate you sharing. Thanks!

      -OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Newbie: confused by the jargon, needing simple guidance...

      @Meldrew-s-mate I see you're trying to get a sip of water through a fire hose.

      Start off slowly and build from there. First get your Cerbo-GX running and collecting data from your battery and solar panels. Hopefully you were provided a manual or a link to one.

      Keep it simple; that is, connect to the Cerbo-GX using a web browser. (While a display is cool to look at, you probably won't use it much.) Once you're comfortable with that, go onto Node-Red and do some of the tutorials.

      Have a goal in mind. (eg. "I want to see a graph of my energy production")

      Personally, I know essentially nothing of Node-Red.

      I do know MQTT and it sounds really complicated at first, but it is actually very simple, (ok, but with some tricky, cool, stuff, too) MySensors can communicate through MQTT.

      Like @nagelc noted, MySensors is about basic sensors (relays, pressure sensors, flow meters, lights, motion sensors, etc.) These are the sensitive finger tips of your entire system. For example, a low cost energy meter.

      Node-Red is a controller, that is, it takes the information from sensors and acts upon that information. In your case, probably, DC and AC voltage, current, power, and energy for the solar panels and energy level of your batteries.

      What do you want to do with this information? eg. It's been overcast for three days and it's going to be for another six so you want to prevent certain devices from turning on.

      Home Assistant is a pretty good controller, but the arrogance of the people there will send you 'round the bend. They have a great forum, but only if you play by their rules. Again, I can't speak to Node-Red's forum. There's a bit of cross-over between Node-Red and Home Assistant, that's why I mention it.

      So once you're up and running and you get the urge to some really trick stuff with Arduinos and/or ESP32/8266 come on back. I'm working on my second release of a Universal Light Switch.

      -OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: Soil Moisture Sensor Powered by solar charged battery

      @CrankyCoder

      TP4056 Charge controller Not exactly designed for it, but it works.

      The sealant was liquid tape If I have to open it up, I just score it with and exacto knife and after reclosing, more liquid tape. Note also I use a clear lacquer spayed onto the electronic parts (after soldering) to minimize corrosion. I also put in one of those desiccants you find in vitamin bottles. Have a look at the spreadsheet Bill-of-Materials

      My sample period is 1 hour. If I'm sending a message from HA to the Arduino it takes two hours to get there, if it gets there at all. Fortunately, the only message I would ever send is to change the sample period.

      What is the locking solenoid valve you use?

      I've thought about putting smarts on my valves instead of the RPi and relay board. I have wires going to all of my 20 valves (non-trivial 5 x 5 "cross-bar", gravity fed, 9 terraces, 3 micro-climates) My environment is very sunny and corrosive (coastal) so I have 0 pressure brass valves.

      What I was thinking was a tasmotized ESP01 relay with a 24VAC to 5VDC power supply. Then only two wires for the power are needed. The device could also be used when that last spare irrigation wire breaks.

      I run HA in a VirtualBox in Ubuntu on a refurbished tower. Mosquitto is also running on that computer as well as my valve controller frontend SIP (Sustainable Irrigation Platform)

      posted in My Project
      OldSurferDude
      OldSurferDude
    • Soil Moisture Sensor Powered by solar charged battery

      A seemingly simple project that employs some challenging programming techniques: calibration, power failure recovery, low power usage, two way communication with Home Assistant, 3D enclosure and more ...

      See Remote, Solar Powered (with battery backup) on github for more details

      This device is a soil moisture sensor that determines a relative number between 0 and 100 indicating completely dry to entirely wet. The number is sent to a controller for further analysis and/or action. It is battery powered and the battery is recharged using a small solar panel. The device is required to be calibrated and the calibration routine is part of the software.

      The components are: a soil moisture sensor, an Arduino Nano with an nRF24 radio, an 18650 Li-Ion battery, a charge controller board and a solar panel. The housing is made up of 3D printed parts.

      This device is part of a system that also includes a gateway and a controller.

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Code Garage to the rescue.

      @fsgraz As an alternative to MySensors using the nRF24 radio, look at the work that tmrh20 has done. I have used this code and found it works well enough. It's lower level than MySensors. I haven't tried to connect it to Home Assistant, but I think a determined person could make this happen.

      I would say it doesn't have the support that MySensors ha,s being only one person, but there isn't much support here anymore. 😞

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: 💬 MySensors InCan double light switch

      The author has done some good work ensuring good design practices; trace separation, fuses, etc. but I don't see any extra I/O brought out on this particularl switch. You would have to carefully solder to the chip itself, and modify the code a bit.

      You could use magnetic switches. Put a magnet on the blinds and the switch in window sill.

      The author notes that this is not an Arduino, but uses the same chip that the Arduino uses. The author doesn't explain how the chip is programmed. This method could have been used.

      It may be just as easy to use an RF Nano with a little power supply. This suggestion is not nearly as robust as the author's. For example, these power supplies have gotten bad reviews mainly because the mains power traces are too close together. I justify using them because in all likelihood a failure will pop the power supply and probably the Nano, too, noting that these are cheaper than the fuses you would put in to protect them. I am fully aware of the risks involved in doing this, and you should be, too (eg. burning down your house).

      -OSD

      posted in OpenHardware.io
      OldSurferDude
      OldSurferDude
    • RE: Status of my rv(camper) home automation system 2020-2025

      I think it's pretty cool. I can hear my spousal unit asking, "What are you doing with all that data?" 😉

      -OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: DHT22 wrong sensor type in Home Assistant

      I'm glad that worked!

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: DHT22 wrong sensor type in Home Assistant

      Good call @skywatch !

      wait() is a MySensors function that looks for MySensors operations that run asynchronously to loop(). Search for "What is the difference between delay() and wait()"

      I have experienced the symptoms you describe. I put a wait() after functions that send MySensors data: send() and present() (but for some reason not sendSketchInfo()?). If I'm using an MQTT gateway Its 500 and 4000 milliseconds, respectively; Serial, 100 and 500.

      I think this will work for you! 🙂 Letting us know your results helps someone else that is experiencing what you are.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: DHT22 wrong sensor type in Home Assistant

      I'm going to make an assumption: You have connected to Home Assistant many times during your development.

      Home Assistant is not very flexible with MySensors. If you change Child_IDs it sometimes ignores the change.

      Try deleting your MySensors device. This is not a friendly operation. Assuming that your Uno is acting as a serial gateway and as your sensor monitory device,

      • disconnect the Uno from your computer. th
      • In HA: settings-->Devices and Services-->n DEVICES in MySensors integration-->click on device your going to delete-->3 vertical dots next to Remove Device from MySensors-->>Remove
        Then restart HA
      • Developer Tools-->restart-->restart
        After HA is restarted, plug your Uno back in

      If your MySensors gateway is MQTT you have to stop the MQTT gateway and delete all vestiges of your device in the MQTT broker (I use MQTT Explore to do this which has to be running befor you do anything to see the topics that will be erased.)

      Let us know if that fixed it.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • Interface-board-for-remote-control

      I had many problems trying to bring my motor blinds into my home automation. What I ended up doing was having an Arduino Nano push the buttons of a remote control.

      For the Arduino part, I started with the GatewaySerial example.

      What this project shows is how to connect to a remote and get some primative feedback from the remote.

      So far it works pretty well.

      Find the project on my github page

      -OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Ghost Child

      I want to thank @FcNanoLed. I had long thought about a serial gateway. This would be a way to add I/O to a linux computer. In the process of trying to help, I built up a linux machine running virtual box. In the virtual machine I ran Home Assistant The not well documented part of that was to connect the USB port of the computer to the virtual machine (settings-->USB-->USB Device Filters) (note that one can buy a refurbished PC for about the same price as an equivalently configured RPi)

      So thanks for the inspiration!

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: ESPnow as transport layer

      @MasMat I won't say I'm better informed, as I just scanned some of the documentation. It seems that ESPnow combines many of the OSI layers. These layers exist for a reason and adnerence to them allows for the extent of the internet.

      That said, we don't want our IoT devices to be part of the internet. The low overhead of MySensors communication is required for MySensors to run on Arduinos and inexpensive radios.

      Espressif combines theses two at a lower cost. I need to look into it!

      I found Getting Started with ESP-NOW (ESP32 with Arduino IDE) It's mesh is limited to 20 devices. MySensors is theoretically limited to 254, but in practice my experience indicates about 30.

      I have found the Arduino Nano and the nRF24 very robost, though the tolerances on the radio make it "wabbly" Again, my experience, the ESP8266 is a little fragile (smoked a few) though the radio is awesome.

      I have a project I call The Universal Light Switch. My alpha testing is 20 ESP8266 devices Which uses 20 IP addresses on my router. I discovered that my home routers can only handle about 25 WiFi devices. So ESPnow has my attention.

      posted in Feature Requests
      OldSurferDude
      OldSurferDude
    • RE: Ghost Child

      I saw that, too, but I wasn't sure. This is documented here
      bool present(uint8_t childSensorId, uint8_t sensorType, const char *description, bool echo);

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Ghost Child

      @FcNanoLed
      I have not used a configuration where a Nano is connected directly to the controller. I assume your program has
      #define MY_GATEWAY_SERIAL
      because I when I compiled a sample program without it and without a radio I got the error:
      #error No forward link or gateway feature activated. This means nowhere to send messages! Pretty pointless. 😉

      Your code is probably right, but if you posted the entirety we may be able to find the error. Are CHILD_ID_ARMED, and the IDX_xxxx variables? If this is the case, something could be changing them, which could create the ghosts. Typically, compiler directives are used, eg.

      #define CHILD_ID_ARMED 0
      #define IDX_PORTAIL2 123
      

      I can't think of anything else right now

      -OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • Home Assistant/MySensors quirks

      I just deployed my Remote Solar (with battery) Moisture Sensor. Once I got all of the subtilties nailed down, two lines of code, read and send, bloomed into over 300 lines!

      There were three Home Assistant (HA) related gotchas.

      Gotcha 1. getting data from HA.

      If you have everything coded right, HA will know about your Arduino, but you have to send a datum for each sensor (child_ids) to get HA to know about the sensors. I do this in setup

      But for reasons beyond my understanding, HA won't send anything other than binary. To get around this I send text. That is, the MyMessage is of type V_TEXT and the presentation() is S_INFO

      #define CHILD_ID_SAMPLE_INTERVAL 0
      MyMessage msgSampleInterval(CHILD_ID_SAMPLE_INTERVAL, V_TEXT);
      volatile unsigned long SamplePeriod = 20000; // ms to sleep between sensor reads
      volatile bool SamplePeriodReceived = false;
      
      void presentation(){
        present(CHILD_ID_SAMPLE_INTERVAL,S_INFO,varName); // sensor 0
        wait(REGISTERING_VARIABLES_WAIT);
      }  
      
      void setup(){
        send(msgSampleInterval.set(SamplePeriod));
          wait(MESSAGE_WAIT);
      }
      void loop(){
      
        // read data
        // send data
      
        if (SamplePeriodReceived) {
          SamplePeriodReceived = false;
          // do something with datum that came from HA
        }
        smartSleep(SamplePeriod);
      }
      void receive(const MyMessage &message){
          switch( message.getSensor() ) {
            case CHILD_ID_SAMPLE_INTERVAL:
              // MQTT topic: mysensors-in/177/0/0/0/47
              SamplePeriod = message.getLong();
              SamplePeriodReceived = true;
              break;
      }
      
      

      What's going on?

      • Basic MyMessage, but of type V_TEXT
      • The two variables need to volatile because they can be changed at any time by the background process receive(). This variable must be kept up-to-date.
      • present() is of type S_INFO (see below for varname)
      • Send an initial value in setup() so that HA knows about the variable
      • In loop(), check periodically to see if a datum came in. This is done because you want to keep the receive() routine as short as possible. Also, no sends and no print statements, no long loops, etc. in receive(). Anything you can do in loop(), do it in loop().

      The data is sent from HA as text. Doesn't matter, the message.getTYPE(); will convert it for you.

      Gotcha 2. I use an MQTT gateway. I have a wait() after every send(). I'm not sure why; my guess is that if you send to fast, the data gets overrun. For sending messages, I use 300mSec. For presentation is use 4000 mSec!!!!

      Gotch 3. Beauteous! I got it all working. Time to turn MY_DEBUG off. To ensure it is off:

        #ifdef MY_DEBUG
          #undef MY_DEBUG
        #endif
      

      It stopped working and, because MY_DEBUG was off, I couldn't figure out why. I put it back in, worked fine. It dawned on me that those debug statements took time. I added 200mSec, yes, a full half second! (Lieutenant Commander Data: 0.68 seconds sir. For an android, that is nearly an eternity.)

      Do not use delay(), that stops all processing. wait() will allow the background process to function, such as receiving data. The syntax for wait() is bool wait(unsigned long ms, uint8_t cmd, uint8_t msgtype); which will wait for the first condition to be true, but I am unable to find the cmd or msgtype. To wait for those would be much more elegant.

      • below varname

      varname This is the name that HA uses in automations, scripts, etc. The problem comes when you have two Arduinos that run the same code. HA appends an arbitrary number to the end of the variable name. This leaves you to root around HA to find out what that was. I programatically append the node number to my varname. varname must be of type string (an array of characters the byte after the last character set to 0) as opposed to type String. Using type String is not advised as it is very easy to add to the String so much that it wipes out memory beyond its bounds. A real bugger to debug, especially if it occurs in receive().

      • HA script to change interval period to 4001 mSec (assumes varname is "int177"
      sequence:
        - target:
            entity_id: text.int177
          data:
            value: "4001"
          action: text.set_value
      alias: moisture sensor 177 Sample Period 4001 HA
      mode: single
      description: Send text to change sample period to 4001
      
      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: Ghost Child

      @FcNanoLed I'm a Home Assistant (HA) user so I don't know if this is applicable to you.

      I am assuming here, because your nano is connected to your RPi through a USB port that your nano is running MySensors Gateway code. I believe that both gateway and node code has to have a radio connected to start. So I assume this, too.

      The source could be an errant RF signal caused this, though unlikely.

      Ghost devices in HA also show up when a device gets assigned a new node on a reboot, or were deleted improperly, eg. not deleted using the controller environment.

      In either case, what has to be done in HA is basically remove all vestiges of the MySensors environment best you can.

      • Ensure that the code on the device(s) that has the sensors (child) is(are) working properly
      • Power down this(these) device(s)
      • if you have a gateway, stop or power it down
      • Delete this(these) device(s) from the host program
      • Delete the integration (this is what the code running in the Controller is called in HA)
      • If you use MQTT, use a program like MQTT Explorer to remove all vestiges of MySensors.
      • reboot the Controller (HA in my case)
      • reinstall the integration
      • restart the gateway
      • At this point you may still see the ghost!
        ** list itemFor each ghost, create a device that looks like the ghost then delete it using the controller interface.
        ** Then reboot the host again.
      • finally reconnect all of your valid devices.

      Yes, it is a pain in the ***! Has a lot to do with recoving after a power failure, backups and trying to accomodate all possible scenarios.

      Hope this helps

      -OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Door chime

      @Paul-Scarbro There are multitude of solution, but since we are in MySensors Land, let's do a MySensors solution. You'll quickly see that doing that adds a lot of overhead.

      We'll use an Arduino Nano or RF Nano if you're going to go whole hog. It can be run from 3.3V or 5V DC, not AC.

      The reed switch would be connected to an input of the Nano and one of the outputs would drive a relay. The relay would drive the chime.

      Your C++ program would be something like:

      #define inputButton 2;  // connect reed switch here
      #define outputRelay 4;  // connect relay to this pin see MySensors Relay example
      #define RELAY_ON 1  // GPIO value to write to turn on attached relay
      #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
      
      
      void setup() {
        pinmode(inputButton,INPUT);
        pinmode(outputRelay,OUTPUT);
        // put your setup code here, to run once:
      
      }
      
      void loop() {
        // put your main code here, to run repeatedly:
        if (digitalRead(inputButton) == 0) {
          digitalWrite(outputRelay,RELAY_ON);
          wait(2000); // wait 2 seconds
          digitalWrite(outputRelay,RELAY_OFF);
      
          // now wait for door to close
          while(digitalRead(inputButton) == 0) ; //does nothing until reed switch opens
          
        }
      
      }
      

      There are some subtleties that I may have glossed over, but this is the gist.

      By looking at the MySensors Relay example, you'll see how to integrate this into a MySensors environment. That's where you'd want to get the RF Nano.

      I've made the assumption you're familiar with the Arduino IDE and you've looked into the MySensors environment.

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: MQTT-Help me understand about the MQTT Gateway.

      @dpcons MQTT sounds intimidating and looks imitimidating when you see all of the options available.

      Here's the scenario:

      • You want to send a message. That's the -m option followed by a space and the message between " "
      • the location, topic, is a tree, -t option, separated by forward slash / eg. MyRootTopic/MyTopicsSub/MyTopicSubSub

      It's as easy as that if your broker, the MQTT service (program) is on the same computer as the sending program. Usually it's not.

      • Specifiy the location, the host, of the broker with the -h option followed by the host name or IP address

      The retain option, -r is important but explaining it is beyone the scope of this message

      Receiving, subscribing, to a topic is just the same, but you wouldn't have the -m message

      If you subscribe from the command line, the subscribe function waits indefinitely for messages published to the subscribed topic (unless you use the -C option) ^C to terminate the command.

      A tamotized device with the MQTT configured will create a number of topics on the broker. Home Assistant will see this automatically, if you have the Tasmota and MQTT Integrations installed.

      The MySensors MQTT gateway takes care of MQTT communication for a MySensors device. Again the MySensors and MQTT integrations.

      I use both.

      -OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: MQTT-Help me understand about the MQTT Gateway.

      @dpcons that is correct. The ESP communicates directly with the MQTT broker.

      It's very easy if you're ESP has been Tasmotized. I am of the understanding that one can compile their own Tasmota binary to suit particular needs. I have not done this.

      If you're using the Arduino IDE to program your ESP, it is possible to communicate directly to the MQTT broker. You will have to come up with your own protocol though, This I have done and it takes some perseverence.

      Both Tasmota and Arduino IDE accomodate Over-The-Air (OTA) updates. This is nice, especially when your device is behind a panel or up the hill. Interestingly enough, if something is Tasmotized, an Arduino IDE binary can replace it OTA; and vice versa. This I have done many times. (Yes, some failures to communicate and a hike up the hill 😉

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: MQTT-Help me understand about the MQTT Gateway.

      @dpcons All the esp8266 devices with which I have experience have WiFi and can be Tasmotized. Fundamental to Tasmota is to WiFi; you specify the SSID and passphrase. Also fundamental to Tasmota is connecting to an MQTT broker; you supply IP address and, if necessary, name and password. In addition, there exists DHTxx configurations. Load this software and your data is going to the broker.

      (Home Assistant has an integration for Tasmota whch requires the MQTT integration.)

      I have done this many times and for me it takes less time that it did to write this response to get a DHT12 putting data to the broker. Tasmota is incredibly well supported, so it shouldn't take you much longer.

      I make the assumption that you already have a way to program the esp8266. The process to which I refer ggoes something like this:

      • Put your esp8266 in the programmer
      • connect your programmer to a usb port of the your computer
      • open the tasmota web installer
      • In following the istructions, be sure to do the load SSID/passphrase, if you don't you'll have to connect to your esp8266 over WiFi (http://192.168.4.1) and enter them on that web page. If the connection goes well, an IP address on your network will be presented... briefly.
      • Once your esp8266 device is connected to your WiFi, you connect to the ip address of your esp8266 device.
      • from there, after searching "Tasmota DHT12" you can configure you esp8266 device to read your temperature sensor.

      All that said, I still like an Arduino Nano with the nRF radio (or an RF Nano) and MySensors. I have yet to brick or lose the program of a Nano but have done both on several esp8266's.

      OK, back to what I came here to do ... make a serial gateway. 😉

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: Nb of possible nodes in a mysensors networks with domoticz

      @Sasquatch
      Because I have the exact same code for all same devices, I need to predefine the node ID. Your method is to run simple code with MY_NODE_ID set so that this sets the EEPROM. I like it, though I'm a little uncomfortable with it in that I am uncertain that MySensors won't change it...I can get comfortable with it. But it's still running some simple code before loading the real code. And, the gateway has to be up and running.

      If one is comfortable with MySensors taking the NodeID from the EEPROM, then my code to get the NodeID in the "real" program is redundant.

      I think I did this because I was re-using my Arduinos and was unaware of the "MySensors gets new node only if address 0 is 0xFF". I got frustrated that I was getting duplicate node IDs, so I forced the issue.

      In the future, I will make a note in my comments something like:

      /*
      MySensors gets NODE_ID from address 0 of the EEPROM.
      If this value is 0xFF a random NODE_ID will be assigned
      */
      

      Thanks for making it clear for me.

      Now I remember ...

      I booted up a 10 device system, all with 0xFF and the MySensors nettwork went bonkers, Most of the nodes had to go through repeater nodes (default is set to make nodes repeaters) and these repeater nodes stole the data because they had the same temporary address. Sometimes it would take hours for the MySensors network to get it all sorted out.

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Nb of possible nodes in a mysensors networks with domoticz

      @Sasquatch I do see what you mean about RTFM. Of course, that's the way one would do it if one only had one or two devices. My suggestion was biased by my situation

      I have 7 nodes that have identical code except for the node number. The location of the sensor and the node number are linked and I keep track of these. The challenge is that when I update the code, I would have to compile it 7 times. But if the node number is in the EEPROM, I only have to compile it once. (My code takes several minutes to compile.)

      This is how I upload the code multiple times without compiling multiple times:

      With [in Preferences] Show verbose output during ... upload checked, I compile and upload to one of my devices. I capture the third line which looks something like:

      "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/Blink.ino.hex:i"
      
      

      Then I export the binary (sketch--.export compiled binary or <ctl><alt><s>) The exported binary file name is Sketchbook location/sketch name/build/arduino.avr.nano/sketch name.ino.hex. eg.

      C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano\_Blinkx.ino.hex
      

      This file name will replace C:\Users\**user**\AppData\Local\arduino\sketches\B27BE0BD09045C16054140637AB4EF50/_Blink.ino.hex in the above captured command. (between "-Uflash:w: and :i")

      To upload the file, without compiling, paste the modified command into a command line window:

      "C:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\**user**\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM14" -b115200 -D "-Uflash:w:C:\Users\**user**\Documents\Arduino\_Blinkx\build\arduino.avr.nano/_Blink.ino.hex:i"
      

      I tried to be as generic as possible. Mine is a windows installation. user is replaced with your-user-name. My program was a saved version of Blink. My com port "-PCOM14", was 14. The location of the download program and the configuration file are also installation dependent. That's why I copy it all from the upload output.

      OK, I have to compile twice, but only 1 time would I have to compile twice, because subsequent changes I would export-compiled-binary and use the same command.

      When a device fails, I put the NODE_ID of the dead device in to the EEPROM as above and load the program.

      So, yeah, RTFM. But sometimes the FM is doesn't connect the dots. That's why we have the forum. And, truly, thanks for the comment because I wasn't clear as to why I did it in such a convoluted way.

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Nb of possible nodes in a mysensors networks with domoticz

      here's one of my programs I use to set the node ID in EEPROM:

      #define Ver 1.0
      
      #include <EEPROM.h>
      
      // ------------------------------------------------------------------------------------clearSerialBuffer
      void clearSerialBuffer(){
        while(Serial.available()){
          Serial.read();
          delay(50);
        }
      
      }
      // ------------------------------------------------------------------------------------header
      void header(){
        uint8_t EEpromInt = EEPROM.read(0);
        Serial.print(F("Current value at address (0) is "));
        Serial.println(EEpromInt);
        clearSerialBuffer();
        Serial.print(F("Enter a an unsigned integer >0 and <254: "));
      }
      
      // ------------------------------------------------------------------------------------setup
      void setup() {
        Serial.begin(115200); Serial.print(F("\n\rAddress As uint8_t ver ")); Serial.println(Ver);
        clearSerialBuffer();
        header();
      }
      // ------------------------------------------------------------------------------------loop
      void loop() {
        
        if (Serial.available()){
          long inInt = Serial.parseInt();
          if (inInt <= 0 || inInt >=254){
            Serial.print(F(" I don't like '"));
            Serial.print(inInt);
            Serial.println(F("'"));
          }
          else {
            EEPROM.write(0,uint8_t(inInt));
          }
          header();
        }
      }
      

      One would run it once in the Arduino, then load the actual program..

      This boiler plate show how to set the variable (and set up for data coming from Home Assistant

      #define VER "01"
      #define PROGRAM_NAME "PROGRAM NAME" // " " is required
      
      // compiler directive to select development vs production environment
      // comment out directive for production environment
      #define DEVELOPMENT // MySensors Gateway on channel 86 otherwise 121
      
      // Setting Node ID from EEPROM
      #include <EEPROM.h>
      unsigned short MY_NODE_ID = EEPROM.read(0);  // get NODE ID
      unsigned short dispMY_NODE_ID = MY_NODE_ID;
      
      /*
        ver 01
      	Make notes for each version change
      */
      #include <LibPrintf.h>
      
      //--------------------------------------------------MySensors parameters
      
      #define MY_DEBUG
      
      // radio type, radio control pins and channel 
      #define MY_RADIO_RF24
      // this matches the nRF24 nano
      #define MY_RF24_CS_PIN 9
      #define MY_RF24_CE_PIN 10
      #ifdef DEVELOPMENT
      #define MY_RF24_CHANNEL 86
      #else
      #define MY_RF24_CHANNEL 121
      #endif
      #define MY_RF24_PA_LEVEL (RF24_PA_MAX)
      
      #include <MySensors.h>
      // these wait periods seem to be necessary 
      #define WAIT_AFTER_SEND_MESSAGE 300,0              // ms to wait after send message
      #define WAIT_AFTER_PRESENTATION 5000,0 // ms to wait after presentation message or echo was returned
      
      // configure communication protocol to Home Assistant for power, energy, voltage, current, VA, and powerfactor
      #define CHILD_ID_SENSOR_0 0   // Id of the sensor child
      MyMessage msgPOWER(CHILD_ID_SENSOR_0, V_WATT);
      
      // HA can only send text data.  If the text sent is a number, Arduino can read it as a number.
      // The MySensors integration into HA cannot send numbers, but can send text.  The Arduino must define a “sensor” as V_TEXT, present it as S_INFO, and as above any value sent as it ends up at HA as text.
      #define CHILD_ID_receive_from_HA 7      // ID of entity that receives numeric data from HA sent as text
      MyMessage msgFrom_HA(CHILD_ID_receive_from_HA,V_TEXT); // for receiving number of counts as text
      
      
      
      //------------------------------------------------------before (starting MySensors)
      // This will display program information before attempting nRF24 network connection
      void before(){ // this happens before MySensors starts
        analogReference(EXTERNAL);  // this needs to be done very near the start so ADC doesn't get buggered
        // usual program information at very start
        Serial.begin(115200);
        #ifdef DEVELOPMENT
        Serial.println("---------------------------------- DEVELOPMENT ----------------------------------");
        #endif
        Serial.print(PROGRAM_NAME);Serial.print(" version ");Serial.println(VER);
        Serial.print("Channel ");Serial.println(MY_RF24_CHANNEL);
        Serial.print("Node: ");Serial.println(dispMY_NODE_ID);
      }
      //-------------------------------------------------------presentation
      void presentation(){
      	sendSketchInfo(PROGRAM_NAME, VER,true);  // "true" means send echo request
        wait(WAIT_AFTER_PRESENTATION);
        
      	present(CHILD_ID_SENSOR_0,S_POWER,"Sensor_0_name",true); 
        wait(WAIT_AFTER_PRESENTATION);
        
      	present(CHILD_ID_receive_from_HA,S_INFO,"Data_for_MySensors_sensor",true); 
        wait(WAIT_AFTER_PRESENTATION);
      }
       
      //------------------------------------------------------setup
      void setup() {
        
        // request last known kWh value from gw/HA
        send(msgPOWER.set(-2147483646),true);       // an ENERGY of 1  is ignored, used to sent the energy to no zero
        wait(WAIT_AFTER_SEND_MESSAGE); 
        wait(WAIT_AFTER_SEND_MESSAGE); 
        send(msgFrom_HA.set(0),true); // Ensures that HA sees the "sensor" 
        wait(WAIT_AFTER_SEND_MESSAGE); 
        wait(WAIT_AFTER_SEND_MESSAGE); 
       
      }
      
      volatile bool MsgReceived = false;
      volatile long NumberFromHA = 0;
      //------------------------------------------------------loop
      void loop() {
      //------------------------cumulative energy one-time initialization
        if (MsgReceived){  // message came in from HA
          MsgReceived = false;  // note that this message was processed
      
      	// Deal with message received from HA
      
        }
      
        // Other loop stuff
      
      }
      
      //------------------------------------------------------receive
      void receive(const MyMessage &message) {
        if (message.getType()==V_TEXT) {
          if(message.getSensor() == CHILD_ID_receive_from_HA) {  // filters out ACK messages and ensures that the data is what was intended
            MsgReceived = true;
            NumberFromHA = message.getLong();  // the reads the text sent and stores as a long integer
          }
        }
        //printf("Received Message --- command: %d Type: %d\r\n",message.getCommand(),message.getPayloadType());
      }
      

      I hope this helps

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: 💬 Components

      @GLAB said in 💬 Components:

      nrf24l01+

      I have run the RF24 libraries in 230kbs and that worked for me. I cannot confirm MySensors, but I would assume "yes"

      OSD

      posted in Announcements
      OldSurferDude
      OldSurferDude
    • RE: Nb of possible nodes in a mysensors networks with domoticz

      I set all of my node numbers to prevent confusion. I have 4 locations with level sensors (full/notful and empty/notempty) They run identical code. The only way I know which is which is by the node number. Before I load the code into the Arduino, I set the the 0 location of the Arduino EEPROM with the node number. The code reads the EEPROM on boot.

      Many of my communication problems are the result of a loose wire. I spent a lot of time running the Getting Started code in the RF24 library by TMRh20 on two Arduinos to ensure that the Arduino is wired correctly and can send and receive data..

      I mucked-up my system many times and finally decided to create a second "development" system. I use two different channels for the Arduino/MySensors networks. I like the Arduino/MySensors because they are cost-effective; the downside is the radio.

      I started to migrate to ESP devices because of the built-in WiFI. The downside there is that my WiFi network can only handle about 20 WiFi devices. A Unify Lite AP solved this, but now the network costs twice as much as a MySensors network.

      Good luck on your project

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Gateway without a radio

      I forgot to note, that a MySensors network can handle a lot of devices, just how many is up for debate. My Asus router, which I think is typical, can only handle about 25 WiFi connections. This would be a limiter for and extensive ESP network.

      posted in Development
      OldSurferDude
      OldSurferDude
    • Gateway without a radio

      Unwittingly I have been migrating away from MySensors. Partly because of the dwindling users and partly because I can find cheaper, more robust solutions. For about USD$2.50 one can have an ESP8266 with 80-260VAC power supply. I use both Tasmota and the Arduino IDE for programming.

      But, I can't see giving up my RPi Zero 2W gateway because it's running my irrigation system. The irrigation control is Integrated into the gateway as "sensors"

      The irrigation is gravity fed. I have 10 levels and five microclimates, which works out to 20+ zones. This would be a challenge to do on an Arduino Nano.

      I only have one other sensor left in my radio network and I will eventually replace it. Which leaves me with a gateway with no need for a radio.

      I haven't tried it yet, but can the RPi gateway code run without a radio? I ask because the RPi can handle a lot of tasks and the communication with home automation controllers work well. Seems like a good way to go for complex sensors.

      (I may try again with my battery powered mosture sensors which would utilize MySensors )

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: Long time test done with soil sensor!

      I am duly impressed! I tried something similar. I knew that the environment into which I was putting the sensors was pretty harsh ... I only got about a year. I used an 82650 battery, 5W solar cell and a charge controller. Worked well for a short while.

      I think you inspired me to try again. 🙂

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: LAN8720A - will mysensors work with this module

      @Marcin I googled KC868-A12 and came up with only KC868-A128. If this is not your board, please provide a link. Did you mean KC868-A16? AliExpress Note that these are relay driver boards. If you do indeed use relays, you would need a daughter board.

      My link states that this can be programmed with the Arduino IDE which implies that the LAN drivers are not going to be a problem.

      MySensors REQUIRES a radio. I use nRF24; there are others. It would be tricky, if even possible, to connect a radio to this board because there are only 3 free GPIO pins. Thus, this is not technically a MySensors question.

      But you could send and received messages to/from an MQTT broker and have the controller of your choice.

      The real question here is the complexity (size) of the program. My recommendation is just try it yourself. I would recommend Tasmota and do your logic in your controller. If you need very fast response times, then consider programming with the Arduino IDE.

      Cool project! Let us know how it turns out.

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • Water Meter or "How to get Home Assistant to send saved data to an Arduino"

      This is a pretty basic project except that the trick was to get Home Assistant (HA) to store the cumulative water usage and then send it back after an Arduino (re)boot.

      Here is a link to my documentation, such as it is.

      And a link to the Arduino code. (the HA side is in the previous document)

      see also How I delete a node from HA and start over

      posted in My Project
      OldSurferDude
      OldSurferDude
    • How I delete a node from HA and start over.

      If you're here, I'm not going to preach to the choir about HA's arcane ways. This works for me

      • Stop mysgw
      • Using MQTT Explorer, remove from the topics mysensors_out and mysensors_in all vestiges of the node that is to be deleted
      • In Home Assistant (HA) delete the device
        • Settings
        • Devices and Services
        • Under MySensor, click on n Devices
        • Click on the device you want to delete.
        • Click DELETE
          • One can use use Studio Code Server to note that the device has been deleted
        • IMPORTANT! reboot Home Assistant
      • While HA is rebooting, make the changes to the code of your device
      • When you are satisfied with the changes and after HA has completely rebooted, disconnect your device from power.
      • Start mysgw
      • Apply power to your device
      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Running out of nodeId's

      @TheoL Not only did I put in delays, too, but I put in delays that were based upon the ID (which was stored in NVRAM)! This helped.

      caveat: This is probably not accurate be helps to explain the challenges with a large network.

      My initial experience with Arduino/nRF24 was using the libraries from TMRh20. Those libraries allowed a node to be a repeater, but only for 6 nodes. The primary node 0, master, only allowed 6 nodes to connect to it. The nodes connected to it also allowed 6 nodes. Subsequent nodes had to go through one of these repeating nodes. But the depth was only 4 deep. The master assigned node IDs if the node didn't already have one; similar to a MAC address.

      The master also kept track of the addresses (ARP table?). Addresses were 4 octets (base 😎 in the form of D/C/B/A. A node connected directly to the master had an address of 0/0/0/a (where 0/0/0/0 was reserved for the master). A node connected through another node had an address of 0/0/b/a, and so forth.

      But what happens is that a parent node has to mange the data from all its child nodes and their child nodes and their child nodes. Thus a node would get so bogged down dealing with this traffic that it din't do its sensor task very well.

      It is my belief that MySensors either uses TMRh20's libraries or has developed some aspects based on his initial work. I see that that TMRh20 has a version 2 and I have not experimented with it. I did find that MySensors worked better than version 1.

      Thus, my curiosity.

      I am also duly impressed at the magnitude of hardware. Currently a nano like device from Aliexperss is US$2-3, nRF24 ~ US$1, power supply ~ US$1.50, power cord ?, case?, sensors!? While the hardware cost is daunting, even with a PCB it's a lot of work building those up. So, yeah, I'm impressed!

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Running out of nodeId's

      I, too, am duly impressed that you have so many nodes! Please share more.

      I run a "test" and "production" gateways, too. I have a compiler directive in the sensor software that allows me to easily switch from test to production.

      At one time I was running about 10 Nano nodes and it appeared to me that they were colliding with one another, symptom being slow response times As I remember, that occurred mostly on power up after power loss. Often I'd get two nodes with the same ID. I have since put my ID in NVRAM and that helped.

      So I am very interested seeing what you have done.

      --OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Anybody got one / a few spare minimalist rfm69hw shields for wemos d1 mini?

      Thanks for the offer @TheoL ! I have moved on to a differenct project. Also, a lesson that I have learned many times, "If it works, don't fix it!" 😉

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Anybody got one / a few spare minimalist rfm69hw shields for wemos d1 mini?

      You highlight a problem, @kiesel. Considering that each board is effectively US$2.50, it will cost about US$2 to send one and will take a week, if not two or three, to get to you. Not to mention the time spent on handling.

      I am in the same situation as you, I just ended up wire wrapping and judicious use of double stick tape. Not beautiful, but it works.

      Best of luck

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: [mysensors] Not a valid message: invalid literal for int() with base 10: '\x00\x000'

      @kiesel
      The first thing I would try is to plug the Arduino into a serial port and see if there is output. This would have to be on a different port from the one the HA expects. You can use the Arduino IDE to view the out put. It probably will appear to be gibberish, as the BAUD rate must be right. And it will probably be gibberish anyway because it is probably binary. What you will know, though, is that your Arduino isn't bad.

      You may have to reprogram your Arduino.

      Good Luck

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: Water Filtering and Sterilization and Hot Water Recirculation

      Do you do gizmos for open heart surgery, too? I love all the valves!

      🙂

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: 2x BME 280 on 2x arduino nano hangs in HomeAssistant

      @HJ_SK said in 2x BME 280 on 2x arduino nano hangs in HomeAssistant:

      BME280

      I had a similar situation. First you have to delete all the MySensors devices in HA. This is aggravated by HA wanting the devices to be on line before you delete them. You may have to delete the MySensors data in the HA config directory. You may even have to uninstall MySensors from HA. Then shutdown HA. Next, turn off your gateway. Are you using MQTT for messaging? You'll have delete the MySensors data from there, too. (MQTT Explorer is good for doing this)

      Then start HA. Did your MySensors devices come back as zombies? That's the problem. Try deleting them again. Are they data still in MQTT?

      OK, now start again.

      I had documented how to do all this deleting in HA Forum, HA/Discord and here, but I can't find that documentation now. grrrr

      OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Arduino nano and Uno in same My sensors network with NRF24L01+

      @DIY89

      As a matter of fact, I have. But I haven't had a problem. I found that wiring the Uno was a bother, though. Keep your wires between the Uno and radio as short as possible. Try braiding the wires. (sort of like twisted pairs but in this case, "twisted septet". Don't connect IRQ. I solder a male connector on my radios and the twisted septet is soldered to the board and the female connector. This works well when I have to swap radios around. I have even had success with a cat 5 cable, with connector, as long as 30cm.

      Did you try putting the same program in the Uno as the one in nano 2?

      What controller are you using? I use Home Assistant (HA) and it can be a pain, especially when it comes to the not-well-supported MySensors. Sometimes you have to completely uninstall MySensors (delete all devices first) from HA and then reboot HA. Sometimes, even this doesn't work. (Somewhere I documented how to do this, maybe here or HA forum, but I can't find it now)

      Let us know how it goes.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: A low cost energy meter

      @fsgraz

      I like the work you've done! Making a schematic which can be made into a PCB is a skill that I have yet to acquire.

      I appreciate that you have shown me (us) this design, for it gave me serious pause to think. While I point out some areas that would suggest review, I would encourage you fully document what you've done and put it on git.

      I checked out the ACS714ELCTR device and, if I understand it correctly, it has to be in series with the heat pump. The wire to the heat pump is 6AWG (50A). So, yes, the current sensor would have to have it's own PCB with suitable trace widths and separation and high current connectors. The resistance of the sensor is negligible (1.2 mΩ) compared to that of the connectors. (20 mΩ); Even 5mΩ @30A is 4.5W and the sensor is cooking away at 1W!

      One of the concerns I pointed out was that my design probably would nullify one's homeowner's insurance. An in-line with a 50A circuit, would be a greater concern.

      Is the current output the instantaneous current? "5 µs output rise time in response to step input current" Implies that it is, compared to the ~100µs that it takes for the Arduino to read the analog port.

      The sensor reports the current as proportional to an positive analog voltage. This means that the output would look like a full wave rectified AC signal. Determining phase angle Φ would involve noting the time of lowest current comparted to the time of lowest voltage as opposed to zero crossing. In this case, one wouldn't know if that was leading a lot or lagging a little (or vice versa), though practical assumptions could be made.

      One of the things that the people at Open Energy are troubled with is distortion. The energy AC sign wave is not truly a sign wave, typically there is a flattening at the top. Pumps can cause a very distorted signal! But the concern here is, "How much distortion does your measuring device introduce?" In my device, and this would be true of yours, too. there is the ~100µs between voltage and current readings and an additional ~70µs computational time. But chasing down those problems are not the concern of the low cost meters you and I designed. 🙂

      Good work!

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Where to change settings?

      @eiten I believe the IP of the gateway is the same as the computer on which the gateway is running. In my case, I am running the gateway on an RPi.

      As a side note, that very same program is also a sensor (an array of relays to control my garden irrigation).

      When I think about it, I don't know of any other hardware that can usefully run the TCP gateway. Orange Pi?

      -osd

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Where to change settings?

      Hi @eiten

      If you just want to find the IP address of HA you can use the command line (in windows)

      ping -4 homeassistant.local
      

      Find the version of HA is found by: settings-->about

      I use my router to set the IP address of HA.

      At the router you should be able to determine the MAC (media access control) address of HA. This address is six, two digit hex numbers eg E5:16:A7:92:87:BB. If your HA is online, you'll find the MAC associated with the current IP of HA.

      Your router should have a section for DHCP (dynamic host control protocol) When a device requests and IP address from the router, the DHCP routine provides it. The nomenclature seems to be different for every router, but somewhere in the DHCP configuration settings you'll be able to manually associate the MAC to the desired IP address. Save and exit.

      Next time you restart HA it should have the address you specified.

      Note on HA running in virtual machines: The MAC is a random number selected when the virtual machine is created. I believe it may be able to be set when the virtual machine is created. It's very bad to have two devices on the same network with the same MAC.

      I'm not sure one can change the version number. I would not advise doing that.

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: A low cost energy meter

      @KevinT you welcome 🙂

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: MQTT GW on ESP8266 supporting SSL/TLS?

      @bgunnarb I like @eiten 's solution for you.

      Personally, I am not a fan of using cloud/public brokers. Thus I am curious about your system and there is something about it from which I can learn. I would like to understand why you cannot deploy your own mosquitto broker.

      I see your set up as 3 sensor groups defined by the channel used

      #define MY_RF24_CHANNEL ChannelOfSensorGroup
      

      Each sensor group has some number of sensors and one MQTT GW on ESP8266. On the MQTT side, do you distinguish between gateways by using a different host name?

      Something like:

      #define MY_MQTT_PUBLISH_TOPIC_PREFIX "mygateway-nOf3-out"
      #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "mygateway-nOf3-in"
      #define MY_MQTT_CLIENT_ID "mysensors-nOf3"
      #define MY_HOSTNAME "ESP8266_MQTT_GW_nOf3"
      //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68
      #define MY_CONTROLLER_URL_ADDRESS "test.mosquitto.org"
      #define MY_PORT 1883
      

      I must assume your controller (aka Home Assistant) discriminates between through which gateway the data is to flow by way of the different topic names.

      If my "something like" is correct, then changing brokers is changing the IPaddress/URL in your gateways and in your controller (though if the controller is Home Assistant, it may be a bother because the device-id's may change which will make a mess of all the work you've done in HA. This is why I like @eiten 's solution.)

      I hope it's all working for you again.

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: 💬 AC-DC double solid state relay module

      What I didn't quite figure out was how it operates independently as a regular light switch.

      What I find most interesting is that this is 8 years old. There have been some incredible advances in the IoT world in that time. I was about to do a similar thing which morphed into an ESP-12F then added a touch screen. I call it the Universal Light Switch

      Imagine this: All the switches are identical. Any switch can easily be configured to control up to five devices ... and then changed, on-the-fly, to control a different set of devices.

      My design is part of a system that would require a controller (eg. Home Assistant), an MQTT broker, and receiving modules in the devices being switched. It's WiFI which assumes an access point.

      The DIY ULS is under $20 and the off-the-shelf receiving modules are under $10. (About the cost of a non-networked dimmer switch) If one doesn't have the controller and MQTT broker, they can run on an old (5 years?) computer (which is cheaper than an old RasberryPi).

      This project is a good one!

      OSD

      posted in OpenHardware.io
      OldSurferDude
      OldSurferDude
    • RE: Old hardware migration

      @dbemowsk
      I will share my limited MySensors experience with you.

      I'm pretty sure that your old hardware will be compatible 2.3.2 gateway.

      I don't think you can have two MQTT gateways. First, I don't think Home Assistant (HA) will allow you to do that. I would suggest you try it, though, but, obviously, back everything up before you try.

      Now that said, I'm pretty sure you can have add a serial and/or ethernet gateway. Each gateway would run on a different channel.

      I run HA in a Virtual Box (see HA docs for installing it) and the virtual machine is running in an Ubuntu computer.

      On that computer I am running my MQTT broker.

      It's a little tricky poking a hole for a serial connection into the virtual machine. You have to do this if you are going to have a serial gateway. And you'll have to this if you have a z-wave dongle. (I have a Zooz module and have found the documentation at Zooz for doing this)

      I see that you're pretty experienced and I'd advise you to have a development machine on which you would do your experimenting. This has saved me untold grief when things start to get funky. I even developed a script for recreating my development virtual machine because I've buggered it so many times or I want to have a clean install when I'm trying to learn something new. (Latest was ESPHome)

      It's a good project and you, because of your experience, won't have any significant problems. Well, if you're not a yaml or python guy, HA is going to drive you nuts.

      -OSD

      ps, I sent you an email on you switch -O

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: GatawayESP8266 - Compile error

      @eiten That's good to hear! Obvisouly I misunderstood the meaning of

      // How many clients should be able to connect to this gateway (default 1)
      #define MY_GATEWAY_MAX_CLIENTS 2
      

      thinking it meant nodes, but as you say, it means controllers.

      Considering that one can get and ESP12F, a power supply, and an nRF24l01+ radio for it for about US$3 makes the ESP8266 much more desireable than an RPi at US$56.

      There is one thing that is troubling and that is support. Already noted is that the current revision of the ESP8266 board in the Arduino IDE does not support the ESP8266 gateway. It appears that MySensors, too, is losing adherents.

      -OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • Gateways

      I've been experimenting with gateways. I've been using an MQTT gateway running on an RPI zero. I like this because of the fast (relatively) processor with a lot of I/O (I'm running a 25 zone irrigation system).

      I am developing a low cost energy meter and to test it out on my developments system I tried to use a Serial gateway. no joy, see Serial Gateway woes

      Then I tried the TCP gateway running on an ESP8266 (NodeMCU 1.0). To get that working I had to reload the ESP8266 library and the MySensors library. It works great! ... but the example is limited to 2 devices connected to it. Has anyone tried more devices? My experience with an ESP8266 access point (which is limited to 4 clients and pathetically slow) tells me that not many nodes can connected to it.

      I use Home Assistant as a controller. I did discover that the MySensors integration can run the MQTT gateway and the TCP gateway. I wonder if it is possible to have multiple TCP gateways?

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: GatawayESP8266 - Compile error

      I removed both the ESP8266 library and the MySensors library, then re-installed the MySensors Library and then the 2.7.4 ESP8266 library. Works!

      I did see that the default number of nodes is 2. I suspect that as a gateway, it can't handle many nodes.

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: GatawayESP8266 - Compile error

      @ferro Thanks for checking for me. I'll do that.

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • Serial Gateway woes

      I'm working on an energy meter using an Arduino Nano. My prototype works well. It ships its data off to a MySensors Gateway running on a Raspberry Pi (RPi) which forwards the data to an MQTT broker. Home Assistant picks up the data from the broker. (Home Assistant is running in Virtual Box.) Virtual box is running on an x86 computer with Ubuntu OS) This works

      But if I use a MySensors Serial Gateway I can eliminate the RPi and the MQTT broker. I can put the MySensors Serial Gateway on an Arduino Nano.

      What happens, though, is that Home assistant recognizes the serial gateway, and the device is recognized but no data is accepted. When I put a serial monitor on the serial port, I see that the serial gateway is sending the data.
      Has anyone successully run this configuration: Nano<-->(Nano?) Serial Gateway<-->Virtual Box<-->Home Assistant? (Note, official Uno R3 doesn't work, either.)

      The MySensors Serial Gateway example is only modified with my pecularities: nRF24l01 CE and CS are connected to Pins 9 and 10 and the radio channel I use is 86. Also, I comment out the #define MY_DEBUG line

      Virtual Box is set up per the Home Assistant instructions In addition, a serial port must be configured (enable, Port Mode [Host Device] Path/Address [/dev/ttyUSB0]). the same thing can be done from the command line

      VBoxManage modifyvm $VM --usbehci on --usb on --uart1 0x3F8 4 --uartmode1 /dev/ttyUSB0
      

      Where $VM is the name of the virtual machine
      )
      Here's the steps,

      • I remove power from the Arduino Nana device
      • I must leave the Nano running the Gateway in the USB port becase the Virtual Machine won't start without it.
        In Home Assistant
      • Delete all MySensors devices: settings-->Devices and Services-->Devices(tab)
      • Delete the MySensors Integration: settings-->Devices and Services-->MySensors-->Integration Entries (three vertical dots)-->delete
      • Using Studio Code Server, delete the mysensors persistence file (it should be empty at this point)
      • Reboot Home Assistant. Development tools-->[RESTART]-->Restart Home Assistant (I have also tried the option is uder a
        Advanced, including powering off the computer and even re-installing Virtual Box and re-installing Home Assistant in Virtual box)
      • After Home Assistant returns, I configure the MySensors integration for a serial gateway. One quirk, the serial port is /dev/ttyS0, not ttyUSB0
      • I restart MySensors
      • I wait a minute
      • I press the reset button on the Nano running the MySensors Gateway.
      • I wait a minute
      • At this point I can (usually) see the gateway in devices, under the MySensors integration, and, using Studio Code Server, in the MySensors persistant file.
      • I power of the Nano that is the sensor device.
      • I wait a minute
      • I ensure that data is sent from the sensor device.
      • I wait a minute
      • I see the sensor device in the same places as the gateway, BUT none of those places show the data that has been sent.

      Yes, it appears to be a Home Assistant issue, but I suspect a MySensors person wrote the integration.

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: GatawayESP8266 - Compile error

      @ajongen et. al.

      2024 and alll is not well. The unmodified GatewayESP8266 does not compile now
      MySensors 2.3.2
      ESP8266 by ESP8266 (community) 2.7.4

      In file included from c:\Users\gferry\Documents\Arduino\libraries\MySensors/MySensors.h:441:0,
                       from C:\Users\gferry\AppData\Local\Temp\.arduinoIDE-unsaved202412-16144-b9g35b.q5il\GatewayESP8266\GatewayESP8266.ino:114:
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp: In function 'bool can_yield()':
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:96:26: error: too many arguments to function 'bool can_yield()'
        return can_yield(g_pcont);
                                ^
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:93:17: note: declared here
       extern "C" bool can_yield()
                       ^
      
      exit status 1
      
      Compilation error: exit status 1
      

      ESP8266 by ESP8266 (community) 3.1.2

      In file included from c:\Users\gferry\Documents\Arduino\libraries\MySensors/MySensors.h:441,
                       from C:\Users\gferry\AppData\Local\Temp\.arduinoIDE-unsaved202412-16144-b9g35b.q5il\GatewayESP8266\GatewayESP8266.ino:114:
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp: In function 'bool can_yield()':
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:96:26: error: too many arguments to function 'bool can_yield()'
         96 |  return can_yield(g_pcont);
            |                          ^
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:93:17: note: declared here
         93 | extern "C" bool can_yield()
            |                 ^~~~~~~~~
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp: In function 'void esp_yield_within_cont()':
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:102:2: error: 'cont_yield' was not declared in this scope; did you mean 'can_yield'?
        102 |  cont_yield(g_pcont);
            |  ^~~~~~~~~~
            |  can_yield
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp: In function 'void loop_task(ETSEvent*)':
      c:\Users\gferry\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp:200:26: error: invalid operands of types 'void' and 'int' to binary 'operator!='
        200 |  if (cont_check(g_pcont) != 0) {
            |      ~~~~~~~~~~~~~~~~~~~ ^~ ~
            |                |            |
            |                void         int
      
      exit status 1
      
      Compilation error: exit status 1
      
      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Saving last known good state, but not in EEPROM

      @eiten said in Saving last known good state, but not in EEPROM:

      utility meter in home assistant

      This is exactly what I am seeking! Thank you!

      PS I truly enjoy reverse translating! It teaches me how to better understand my first language and it gives me alternate words to use in searches. So a second thank you!

      "Regelmässiges Zurücksetzen" would be best translated to English in this context as "Periodic Reset". In the English version of Home Assistant it is called "Meter reset cycle" (I remember seeing "keep dry" translated as "do not take in shower with you" 😉

      posted in Development
      OldSurferDude
      OldSurferDude
    • RE: Saving last known good state, but not in EEPROM

      I have considered this @karlheinz2000. In a typical case, both lose power at the same time. Then both do not know the count. 😞

      Thanks for the input!

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • Saving last known good state, but not in EEPROM

      I'm working on a low cost energy meter for my heat pump. This meter would be similar to the meter on one's house, but for one device only.

      Currently my problem is storing the cummulative kWh in the likely event of a power outage. A quick search yields a heat pump can consume 2,000kWh a month. I don't wnat to live in such a place, but this is worst case. If I store each integer change in EEPROM, and the EEPROM is good for 100,000 writes, would mean about every 5 years and I have to replace the Arduino. At half that, I'd have to remember to replace the Arduino when the heat pump is replaced. This is not acceptable to me.

      I also have a water meter that suffers from this same challenge.

      My controller is Home Assistant (HA) and I am looking to see how I would have HA store this data and then the Arduino request it upon boot.

      I have experimented with storing the data on the MQTT broker, but have not done so sufficiently to determine if this method is viable. The mosquitto MQTT broker will restore retained data upon reboot, but, apparently not subscriptions. (I hope I am wrong on this.)

      OK, MySensors Universe, "Is there someone out there that has resolved this issue?|"

      OSD

      posted in Development
      OldSurferDude
      OldSurferDude
    • A low cost energy meter

      I am curious to know if my heat pump is actually saving energy. To know this, I would need an energy meter. So I designed and built one. You can see my projoect and I believe it is sufficiently documented for you to build your own. See Energy Meter

      My nephew has done the same and is as curious as I. But he knows nothing of MySensors, and how to get the data presented in a reasonable way. I explained to him it is a small matter. This turns out to be not so. Beyond the aforementioned energy meter, it involves an Arduino MySensors Gateway (hardware and software), Home Assistant (software), Virtual Box (Software), and an i86 computer (hardware) which is running linux (software). Just writing that makes the project sound intimidating. It is not, if you break it down to its constituent parts.

      The Arduino Serial Gateway (GatewaySerial) can be found as an example in the Arduino IDE, once the Arduino library is loaded. This probrammed Arduino will be connected to the target computer vie the same USB cable used to program the arduino. For my environment, I have some modifications. The wiring of the radio to the Arduino Nano is slightly different. CE is wired to D10 and CS is wired to D9. Also, I am using radio channel 86. These changes are reflected in the following three lines which are added after the line #define MY_RADIO_RF24

      #define MY_RF24_CS_PIN 9    // for compatibility with RF-Nano
      #define MY_RF24_CE_PIN 10   // for compatibility with RF-Nano
      #define MY_RF24_CHANNEL 86  // 86 is the development channel 121 is the production channel
      

      Acquiring an adequate computer for the task can be as simple ordering one from Amazon for around UD$85. Discarded laptops can be found for as little $10 sans battery and power supply. The only important requirement is more than 2GB RAM.

      See information about SSH below

      Installing Ubuntu on the computer is tedious but easily done. These instructions are for the server version of the operating system (OS). This version has no graphical user interface (GUI). You will need a monitor and a keyboard. If network manager is not installed (nmcli d doesn’t work) or nmcli d doesn’t indicate a wireless network, the internet port will have to be used. If there is only WiFi, a network client device, which connects to the internet port, will have to be used. Official instructions

      Installing Virtual Box is also a tedious task. By this time you’re pretty used to using the command line.

      Finally, installing Home Assistant will be the training session for working with Home Assistant.

      Information about SSH
      SSH is programs running on your usual desktop computer and the target computer. When you installed the operating system on the target computer, you entered a username and and password. Once the target computer is up and running, and you’ve found it’s IP address (ip address) you can “ssh” from your usual desktop with “ssh username@xxx.xxx.xxx.xxx (the IP address you just found) You will be prompted for the password.

      This is just like being at the keyboard and monitor of your target computer. EXCEPT, you can now copy and paste from your usual desktop computer into the window of the target computer. That is, you don’t have to fret about typing in all those commands.

      Challenge yourself! 🙂 It's all do-able and you can do it!

      OSD

      The answer to your first question is, "Yes, you can do it!"

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: RS485 to custom PCB - comms working, relay not clicking - need helps

      I see that every relay has an LED associated with it and that the LED should illuminate when the relay is energized.

      Are all the LEDs functioning as expected? Is the I/O that is driving the opt-isolator working as expected?

      Also, you could short pins 3 & 4 of the opt-isolator to see if the relay is working.

      I see 7 relays in the schematic IO-A4, IO-A5, IO-A46, IO-A7 connected to IO-MCU and AL-2, AL-D12, AL-D13 connected to Alarm MCU mini-328. The former four are the relays that are not energizing, right?

      Let's assume the LED and the diode of the opto-isolator have a forward bias of 1.5V, The transistor in the MCU will have 0.1v . This means that the voltage across the 1k resistor is about 2V which means there's 2mA flowing when the output of the MCU is low. Is this sufficient to illuminate the two aforementioned LEDs? I'm pretty sure the forward bias is less. The max current would be 5mA.

      I don't see where in the software that the state of the relays are being initialized because loadState is commented out. You may have to write another program to initialize the EEPROM before first use and then load this code or plan of forcing them as part of your bring up procedure.

      Let us know how the shorting of those pins go.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: Gateway on Raspberry pi 1

      @mimaret Here are my options for an MQTT gateway:

      ./configure --spi-driver=SPIDEV --my-gateway=mqtt --my-controller-ip-address=192.168.sss.sss --my-port=1883 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-transport=rf24 --my-rf24-channel=ccc --my-rf24-pa-level=RF24_PA_MAX
      

      I see that you don't have the SPI driver nor the pubilsh and subscribe topics. Check to see to what they default. I do not use the default channel for my production system (the one that actually runs the house). I don't use the IRQ and have seen no problems not having it.

      You have a lot of warnings. I'd ignore those for now. The issue appears to b the library stropts.h

      Try this: In the file ~/MySensors/hal/architecture/Linux/drivers/core/interrupt.cpp comment out the line #include stropts.h

      I think that's what I had to do.

      Let susknow if that works.

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Does MySensors require Arduino Timer 2?

      I have success!

      (oops, that's suppose to be Timer1)

      I only sample for 1/60 of a second. What I did was to back up all the timer registered I used and then resorted them after I was done sampling. (As opposed to initializing the registers in setup and then starting the timer when needed.)

      Now I have a Nano sampling the data and sending it to a MySensors Gateway on an RPi3B+ which then sends it to an MQTT broker runing on an old laptop. Also running on the laptop is Home Assistant running inside of VirtualBox.

      If MySensors does use Timer1, it appears that restoring the registers allows it to be shared.

      //------------------------------------------------------ISR
      ISR(TIMER1_OVF_vect){                    // interrupt service routine for overflow
        TCNT1 = TimerPreloadValue;  // must be first line!  starts the timer counting again
        digitalWrite(TRIGGER_START_SAMPLE_PIN,HIGH);
        samplesVolts[--sample]=analogRead(VOLTS_IN_PIN); // decrement before capturing
        samplesCurrent[sample]=analogRead(CURRENT_IN_PIN);
        digitalWrite(TRIGGER_START_SAMPLE_PIN,LOW);
        if (!sample){  // count down to zero
          digitalWrite(TRIGGER_START_SAMPLE_PERIOD_PIN,LOW);          // indicate that sampling is complete
          samplingEnd = micros();
          TCCR1B &= 248; // turns off timer 
        }
      }
      
      //------------------------------------------------------sampleOneCycle
      void sampleOneCycle(){
        // back up timer registers
        uint8_t TCNT1_b  = TCNT1;
        uint8_t TCCR1B_b = TCCR1B;
        uint8_t TCCR1A_b = TCCR1A;
        uint8_t TIMSK1_b = TIMSK1;
        
      
        // configure timer which starts the sampling
        noInterrupts();                       // disable all interrupts
          TCCR1A = 0;
          TCCR1B = 0;
          TCNT1 = TimerPreloadValue;                        // preload timer
          //TCCR1B |= (1 << CS10)|(1 << CS12);    // 1024 prescaler 
          TCCR1B &= 248; // turns off timer?
          TIMSK1 |= (1 << TOIE1);               // enable timer overflow interrupt ISR
      
          // demark sampling
          sample = NUMBER_OF_SAMPLES; // count down to zero
          digitalWrite(TRIGGER_START_SAMPLE_PERIOD_PIN,HIGH);
          samplingStart = micros();
      
          TCNT1 = 65535; // first trigger right away!    
          TCCR1B |= 1; // turns on timer 
        interrupts();                         // enable all interrupts
      
        // wait for sampling to be complete
        while(digitalRead(TRIGGER_START_SAMPLE_PERIOD_PIN)){};
        samplingEnd = micros();
        
        // restore timer registers
        TCNT1  = TCNT1_b;
        TCCR1B = TCCR1B_b;
        TCCR1A = TCCR1A_b;
        TIMSK1 = TIMSK1_b;
      }
      
      posted in Hardware
      OldSurferDude
      OldSurferDude
    • Does MySensors require Arduino Timer 2?

      I've been working on a low cost AC Energy Sensor. It consists of a 1:1 isolation transformer, a current transformer (CT), an Arduino Nano, some resistors and capacitors and a 90-to-260VAC to 5VDC power supply.

      In order to make ~70 energy samples per cycle I use Timer 2 to initiate when to sample. One energy sample (one voltage, one current) takes about 0.2mSec. I have been succesful in doing this.

      But when I integrate MySensors, my output stops just after the MySensors banner. I suspect that MySensors also uses Timer 2

      I treat MySensors as a black box. For me, fiddling with libraries and what not is a deep, dark rabbit hole. I will be concentrating on "isolating" my use of Timer 2 by restoring the registers when I'm done taking samples.

      Another alternative is to hang an ESP-1S off the serial port and let it pass the data to Home Assistant via my MQTT broker (or directly using ESPHome). Thus avoiding the use of MySensors. The cost of the nRf24 is almost the same as an ESP-1S

      The ESP8266 has only one ADC limited to 1V and I need two. I could use two ESP-01S which cost less than a Nano?

      So much for musing, what about IRQ's in MySensors?

      OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • Gateway stops communicating (again)

      Re: RPI MQTT gateway stops communicating

      My problem is similar, if not the same. Over some period of time, a week or so, the actuators that are part of the gateway stop receiving commands. The aforementioned topic indicates an unstable network, yet I ssh into the RPi and use systemctl to restart mysgw and the gateway starts acting on the sent commands. The RPi zero W does not have an ethernet port.

      Because I can still ssh into the RPi, I don't think it's a network problem. At the moment, all is fine. What can I do to debug this problem next time it happens?

      Thanks for your help,

      OSD

      My system is:
      Raspberry Pi Zero W Rev 1.1
      MySensors Library v2.4.0-alpha
      configuration: --spi-driver=SPIDEV --my-gateway=mqtt --my-controller-ip-address=192.168.1.142 --my-port=1883 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-transport=rf24 --my-rf24-channel=121 --my-rf24-pa-level=RF24_PA_MAX

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: HVAC Controller

      We are of like minds, Don't like the cloud based controls (that's another discussion).

      In my case I have a Bryant/Connex system, heat pump, variable speed fan and 4 zones. There's a lot going on: the 4 zones creates 16 profiles. The fan speed for a profile will depend on the indoor and outdoor temperature. The thermal fluid pump also has to be controlled. A profile will have an optimal air pressure, so there's a sensor there.

      The controller works just fine not being connected to the cloud. But I want to set the parameters remotely, Bryant/Connex can do this. I also wnat the status of the various actuators and sensors to show up in Home Assistant.

      The signals sent over the RS422 are proprietary. My plan was to reverse-engineer the signals. After doing this I'll have to experiment to get the right mix of air pressue, fan speed and thermal fluid flow for each profile.

      I'd like to do the same for my AO Smith heat pump water heater.

      I'd like to follow your progress.

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • RE: Arduino Nano Every problem

      I bought the Every because it implied it was backward compatible with the nano. No, it's not, as we found out.

      Be that as it may, any word on a getting the Every working with mySensors?

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: nano & E01-ML01SP4 gateway

      @bach

      I believe that what @monte is saying that there will probably be little future support for the nRF24 at MySensors. Having tried a different solution using the nano and the RF24 I am very impressed at the MySensors implementation.

      I am uncertain if MySensors utilizes the IRQ capability of the nano/RF24. I assume not and I have found no need for it. That said, you do not want to connect the IRQ because doing so draws an extra 10-20mA! Doesn't sound like much, but in battery operations, people go to great effort to get rid of unnecessary circuitry (remove power LED, and 5V regulator, etc.)

      @monte is saying to use both capacitors 4.7μF electrolytic and 0.1μF ceramic. I use only a 10μF and am having good success, though if I were doing a circuit board, and going for robustness, I'd used both. Put them as close as you can to the radio. I would also seriously consider a ground plane layer.

      I would recommend a socket for the radio. There is some variability in the RF24, mostly depending on manufacturer (particularly if you're getting them from AliExpress!) If your application is extreme, you'll want to sort through to find the one that works the best. (look for the one with the fewest NAKs),

      I have tried put the nano in a socket and have had zero real success at having the radio work with it. I put shielding around it and had some pathetic improvement. I suspect that if you did put a socket for the nano on your board, you would need a ground plane.

      You might want to bring out RX & TX which is handy in looking at the output when you're running off of a battery. I use this and connect the grounds and then nano RX to adapter TX.

      Good luck with your project

      OSD

      posted in My Project
      OldSurferDude
      OldSurferDude
    • Home Assistant "The notify.mysensors service will be removed"

      OK fine (grrrrr) below you'll my implementation of an HA work around

      But I find that the data is sent to a slightly different topic
      mysensorsor-in/0/1/1/0/47
      vs
      mysensorsor-in/0/1/1/1/47

      The data is still received because the code is looking for the sensor, but what's the difference?

      MySensors device code (snippet)

      #define CHILD_ID_ZONE 1
      .
      .
      .
      void presentation(){
      	present(CHILD_ID_ZONE,S_INFO,"Zone");
      }
      .
      .
      .
      void receive(const MyMessage &message){
      	if (message.getSender() == 0 ) {  // Only listen to messages for device on gateway
      		if (message.getSensor() == 1 ) {
      			ZoneToWater = (int8_t)(message.getLong());
                     }
            }
      .
      .
      .}
      

      Home Assistant script

      alias: SendCustomToArduino
      description: >-
        notify.mysensors is deprecated
          Sends to topic mysensorsor-in/0/1/1/0/47
        How to do the same thing using text.set_value service
          Sends to topic mysensorsor-in/0/1/1/1/47
      sequence:
        - service: text.set_value
          target: 
            entity_id: text.zone
          data:
            value: "12"
        - service: notify.mysensors
          data:
            message: 13
            target: Zone
      mode: single
      
      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: ESP32 with LoRa

      @dhanushmh

      I am unfamiliar with an ESP32 as a MySensors sensor; though it certainly looks do-able.

      Only because you won't be using the WiFi of the ESP32, I'd recommend an Arduino. The ESP32 requires 600mA.

      Your radio will use up to 120mA (range of about 2km).

      Of course, these power consideration aren't important if you have power at this remote location.

      There are a couple of well documented hoops in getting the ESP32 board into the Arduino IDE.

      On your RPi, I recommend using the MQTT interface with the MySensors Gateway. This will require an MQTT broker. You could use a public one (not recommended) or set up one on the computer that will be receiving the data into the database.

      I use Home Assistant to receive data. MySensors integrates well into it. I admit that I don't know how to extract data from its database, but it provides an easy way to graph the data.

      So it goes like this

      • Get the Arduino IDE
        Load the ESP32 board
        Select the ESP32 board
        Using the library manager, download the MySensors library
        Start with the example EnergyMeterPulseSensor because your wind speed sensor probably uses pulses.

      • On the RPi you'll download the gateway files. The instructions here are pretty good
        There are three steps,
        configuration (which takes some thought)
        compiling (make) (you can run the gateway at this point)
        installing (make install) This makes the program run on boot

      • Instructions for getting the MQTT broker installed and running are found by searching for "install MQTT broker" You'll need to know the the machine name and/or the IP address of the broker for both MySensors and Home Assistant

      • The learning curve for Home Assistant is tough. Don't be intimidated, you can do it.

      Come back here if you need more help.

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: make erring out on raspberry pi 2 b

      @mrhutchinsonmn I'm not an expert on this code and when I get into a situation like yours, I suspect a corrupted file. So I download the MySensors code again.

      Yeah it's a pain because you have it all configured. To minimize that pain, I create shell script to run the the configure program. I also keep my source files in a different directory from MySensors. When I go to compile the code, I copy the source(s) to the directory(ies) to where "make" expects it(them).

      Sometimes, for me, I've bolluxed things so badly that I reimage the RPi and really start over! I try to document exactly how to start over.

      I admit, it's not efficient nor elegant, but I eventually I get a configuration with which I can live. Documenting what I do is key!

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • testing with different controllers (mqtt brokers)

      I run mysensors (ms) to an MQTT broker to Home Assistant (HA). My experience with MQTT has been great; it's simple and it's a easy way (using MQTT Explorer) to see the communication between ms and HA. ms has a reasonable way to watch the data flow. HA is another story, steep in necromancy, YAML, double secret persistence files, etc.

      So once I get an HA configuration working, I don't want to mess with it. I have a "production" version of HA running devices and a "lab" version when I'm trying to integrate a new device. When I'm satisfied with how the device works in "the lab", I switch it over to "production".

      Right now, what I do to change the MQTT broker for ms is to run the configure program, then "make" mysgw, just to change the MQTT broker. Is there an easier way, like changing an entry in a file?

      posted in Controllers
      OldSurferDude
      OldSurferDude
    • RE: RFM95W sleep() directly after send() often doesn't sleep radio

      @prawnpie This does not surprise me. I was losing data doing multiple sends in a row (node has multiple sensors). Putting a 500mS wait after each send() allowed the data to get through.

      Also, 5mA for 1mS is not a significant draw on any battery (5mA * 1mS = 0.000002 mAh).

      You could experiment with shorter wait times with

      for (unsigned n = 1000;n>0;n--);
      

      then keep lowering n until you find the threshold

      And finally, assuming that the radio does have a flag to indicate that it is not ready to be put to sleep, it would be a real effort to put that into the libraries of all radios and the sleep command.

      Waiting a milliSecond is actually the best solution and I am duly impressed you found it!

      OSD

      posted in Bug Reports
      OldSurferDude
      OldSurferDude
    • RE: Need a Guide to debug MySensor and Home Assistant

      @esa1966
      Sounds similar to the problems I was having. See if what I did works for you.

      Also, I think I remember seeing a variable that limits the number of connections to the gateway. MY_GATEWAY_MAX_CLIENTS ?

      OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Send/update Value from HA to Node

      @esa1966 I make the assumption you're node is an Arduino

      Are you using an interrupt to capture pulses? With this code, you might lose a count from time to time but that would be insignificant:

      volatile uint32_t timeOfPulse = 0;
      volatile uint32_t pulseCount = 0;  // a 32 bit number is good for about 70 years
      uint32_t pulseCountCurrent = 0;            // for flow rate calculation
      uint32_t pulsePeriodThreshholdForFlowing = 150;  // pulse period greater than 150 mSec is not flowing.
      #define FLOW_SAMPLING_TIME 1000
      unsigned long flowSampleTimeStart = 0;
      bool flowing = true;
      volatile double flow = 0;
      volatile uint32_t flowCountStart = 0;
      volatile unsigned long flowPeriodStart = 0;
      
      #define DIGITAL_INPUT_SENSOR 3                  // The digital input to which you attached your sensor.  (Only 2 and 3 generates interrupt!)
      
      double countsPerLiter = 400.0;             // double and float are the same on most arduinos
      /* DIGITEN G3/4" Brass Water Flow Sensor, Hall Effect Liquid Flow Meter Flowmeter Counter 1-30L/min 
       *  n = 6.6
       *  F=nQ L/M (from meter specs) 
       *  n * 60  is pulses (counts) per liter yeilds 400 pulse per leter
       *  
       *  flow rate 1-30 L/min (from specs)
       *  
       *  if time between pulses is greater than 0.15 seconds, there is no flow
       *  
       *  
       // Pulses per liter 
      //-----------------------------------------------------------------------------------ISR onPulse
      void IRQ_HANDLER_ATTR onPulse(){
        timeOfPulse=millis();
        pulseCount++;
      } // make ISR as short as possible.
      //-----------------------------------------------------------------------------------setup
      void setup(){
      	pinMode(DIGITAL_INPUT_SENSOR, INPUT_PULLUP);
      	attachInterrupt(digitalPinToInterrupt(DIGITAL_INPUT_SENSOR), onPulse, FALLING);
      }
      //-----------------------------------------------------------------------------------loop
      void loop()
      {
      	uint32_t currentTime = millis();
        
        // determine if water is flowing
        // if the time at this moment less than the spec threshhold, water is flowing
        flowing = (currentTime-timeOfPulse < pulsePeriodThreshholdForFlowing) ; 
      
        // determine flow during this period and set maximum flow for all periods
        if ((currentTime - flowPeriodStart > FLOW_SAMPLING_TIME) && flowing ){
          pulseCountCurrent = pulseCount;
          flow = double(pulseCountCurrent - flowCountStart)*1000.0/double(currentTime-flowPeriodStart)/countsPerLiter;
          flowCountStart = pulseCountCurrent;
          flowPeriodStart = currentTime;
          if (flow > maxFlow) maxFlow = flow;
        }
      
        
        if (SLEEP_MODE || (currentTime - previousSendTime > SEND_FREQUENCY)) {
          previousSendTime = currentTime;
          pulseCountCurrent = pulseCount;
      
      // MySensors sends here
          
          if (flowing) Serial.print("   "); else Serial.print("NOT");
          Serial.print(F("Flowing"));
          Serial.print(F(" Pulse Count: "));    Serial.print(pulseCountCurrent);
          Serial.print(F(" volume:"));    Serial.print(volume, 3);
          Serial.print(F(" Maxium flow: "));    Serial.print(maxFlow);
          maxFlow = 0.0;  // reset max flow.
      
          Serial.println();
        }
      }
      

      Having HA send data is not so trivial

      On your Arduino you'll have something like this code:

      #define CHILD_ID1 1
      MyMessage msgCustom(CHILD_ID1, V_TEXT);
      #define DELAY_AFTER_SENDS 500
      bool initialValueSent = false;
      int msgCount =0;
      
      //--------------------------------------------------------------------------------setup
      void setup(void) {
      }
      //--------------------------------------------------------------------------------presentation
      void presentation() {
        // Send the sketch version information to the gateway
        sendSketchInfo( "PROGRAM_NAME",1.0 );
        delay(DELAY_AFTER_SENDS);
        present(CHILD_ID1, S_INFO, "CustomSensor1");
        /*
        TextSensor1 will be used as the target.
        YAML script sends "Data from script" to actuator
        alias: SendToArduino
        sequence:
          - service: notify.mysensors
            data:
              message: Data from script
              target: CustomSensor1
        mode: single
      
        */
      }
      //--------------------------------------------------------------------------------loop
      void loop() {
        if (!initialValueSent) {
          Serial.println("Sending initial value");
          // Send initial message as per Home Assistant docs.
          send(msgCustom.set(0));
          delay(DELAY_AFTER_SENDS);
        }
      }
      //--------------------------------------------------------------------------------receive
      void receive(const MyMessage &message) {
        if (message.type == V_TEXT) {
          if (!initialValueSent) {
            Serial.println("Receiving initial value from controller");
            initialValueSent = true;
          }
      
          // Dummy print
          Serial.print("Message: ");
          Serial.print(message.sensor);
          Serial.print(", Message: ");
          Serial.println(message.getString());
          // Send message to controller
          send(msgText.set(message.getString()));
          delay(DELAY_AFTER_SENDS);
        }
        Serial.print(F("count: "));Serial.println(++msgCount);
        Serial.print(F("Type: "));Serial.println(message.getType()); 
        Serial.print(F("Data: "));Serial.println(message.data);
        Serial.print(F("Long: "));Serial.println(message.getLong());
        Serial.print(F("Float: "));Serial.println(message.getFloat());
        Serial.print(F("Sensor: "));Serial.println(message.getSensor());
        Serial.print(F("isAck: "));Serial.println(message.isAck());
      }
      

      The commented out code starting with "alias" is the YAML script that will be used to send your data. Note that in this example, "Data from script" is the data that will be sent.

      One annoying thing is that the service "notify.mysensors" can't be found until after you've run the Arduino code. But then, now that you know what the service is, you can probably just put it in your code and see what happens.

      Good luck

      OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Local Sensors on Raspberry Pi Gateway

      @mfalkvidd

      I finally got it to work. Look at my post on the Home Assistant forum.

      There is an amazing thing that someone in the MySensors world did that makes RPi I/O very easy! Just like the Arduino, one uses the code:

      pinMode(MphysicalPin, OUTPUT);
      

      I couldn't believe my eyes when I saw that. And then got double flabbergasted when I discovered that pin is the physical pin of the RPi! No mapping of GPIOi to the pins.
      Whew!

      So the I/O was easier than both of us could have imagined! @mfalkvidd if you know who did this, send them praise and thanks.

      OSD

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • RE: completely remove MySensors integration for HA and start over

      @OldSurferDude I posted this question in the Home Assistant forum, too. I figured it out! See my post in HA

      OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude