Navigation

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

    Posts made by alowhum

    • RE: MySensors in a NERF gun - a question about capacitors

      I thought I'd give an update.

      I added four .470 capacitors in paralel, but the gun was still turning itself off. Then I added the diode, and.. it worked! The gun remains stable.

      ...at least.. while it was on a beefy lab power supply. It indicates that when firing the gun uses about .6 amps, and it prefers to be around 8.5 volts (6 AA batteries). 9 volts seems to be too much.

      I tried to switch it to the intended portable design, with a USB PD decoy feeding into a 4A up-down adjustable buck converter.

      But then it crashes again.

      For example, I tried this:

      • 55W steam deck USB-C PD power supply ->
      • adjustable decoy set to 15 or 20 volt.
      • down-converting that to 8.5v with the buck converter.

      Maybe all this power converting means that it can't provide the sudden increases in power when the motor spins up?

      Perhaps using a linear DC-DC converter work better? Or maybe the USB-PD decoy just can't handle it? It's a mystery.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: MySensors in a NERF gun - a question about capacitors

      Thanks. I'll look into it.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: MySensors in a NERF gun - a question about capacitors

      @ejlane Could a resistor be used for that?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: MySensors in a NERF gun - a question about capacitors

      I think capacitors with a blocking diode would be the right call..

      Cool!

      That calculation clears up so much. Really great explanation, thank you!

      It seems a diode is needed either way.

      The power supply runs both the Arduino the blaster itself, which means the two motors it uses. One motor spins the barrel (purely as an optical effect), and other one actually shoot out the darts.

      for a hobby level project maybe simply going 10x for a few pennies more would be a good idea

      Glad to hear that (other than cost) there is no problem with using a way too big capacitor. That also simplifies building up a stock 🙂

      posted in Troubleshooting
      alowhum
      alowhum
    • MySensors in a NERF gun - a question about capacitors

      So I have this huge NERF gatttling gun that I was trying to have some fun with. I wanted to be able to lock or unlock the trigger remotely based on face recognition, which is handled by a mobile phone at the front of the gun.

      The problem I ran into is that whenever the gun's motors spin up then cause a power loss to the arduino. Now I could add a separate power supply for the Arduino, but it would obviously be much cleaner if it looks like a normal gun from the outside.

      So I figured I needed some kind of "electrcity buffer" that would continue to provide the Arduino with stable power whenever the motors spin up.

      I realised I know very little about capacitors.

      • Which type do I need? Some are "aluminium high frequency". Are motors high frequency? Should I get those? Do they charge up faster?
      • Is there any risk that a capacitor makes the situation worse? E.g. if it's empty and it sucks up electricity that should be going to the Arduino?
      • Some go up to 400 volts. Some seem a perfect match at 5.5 volts. How do you choose what voltage rating to get? Is there a trade-off? Is it wise to go a few volts above the voltage in your system?
      • I figured I wanted as many Farads as possible? So I found these capacitors with 4F. But I realised I have no idea if that's a lot. How can I compare it to, say, batteries? How long can a 4F 5.5v capacitor run an Arduino nano + radio?
      • Is there a downside to having a lot of Farads, other than the cost?
      • How do I make sure the energy in the capacitor is "reserved" for the Arduino? After all, the motors are on the same circuit, and could perhaps suck it dry instead?
      posted in Troubleshooting
      alowhum
      alowhum
    • RE: 💬 6Gang30AmpsLatchRelayEspHomeReady

      Incredible. The "yeah it's a hobby" terrain has been left far behind.

      posted in OpenHardware.io
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      If you want the latest developments if this addon, please use the Candle Controller instead of the Webthings Gateway. Candle is a fork of Webthings that I also work on. Going forward it's your best bet for updates.

      https://www.candlesmarthome.com

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Where did everyone go?

      I used MySensors to create a privacy friendly smart home demonstrator called Candle. Quite a few people are building it, but they may not even realise they are using MySensors.

      In this project my own attention certainly has shifted a bit. Cheap Zigbee dongles and devices aid my goal of moving Candle in a more consumer friendly direction, so that people could just buy most of the parts ready-to-go, and still keep everything local. Some devices will still be MySensors devices, simply because there aren't any privacy friendly alternatives that I know of. But a temperature and humidity sensor, those use Zigbee for me now. And I'm moving the privacy features from the arduino code into the central controller instead.

      Speculation about other factors:

      • Practical Arduino hardware education isn't happening right now because of covid. And even there, there are so many hardware options now. Microbits, ESP32, etc.
      • I've also noticed people asking about standardisation, and caring about interoperability.
      • There are many more products available now. Edge cases are being catered to, e.g. gardening.

      Things that might help for me:

      • I really wish there was a cheap, widely available Arduino akin to the RF-Nano, but with RFM69 433Mhz. MySensors has always had range issues for me on 2.4ghz.
      • The MySensors implementation doesn't make it easy for devices to describe the UI they would like. E.g. if a device is read-only or toggle-able is currently dependent on the type, instead of being a factor that can be set for each sensor type independently.

      A new website with a strong focus on new users, USP's (cheap privacy & friendly, or just fun, educational and artisanal) and up-to-date examples might help.

      This all may sound critical, but that's not the intention. I really dig MySensors. It's definitely in my toolbelt.

      posted in General Discussion
      alowhum
      alowhum
    • RE: HomeAssitant MySensors plugin Roadmap

      I've also used them both. Now I'm a very happy Webthings Gateway user. Try it!

      [edit by nca78] fixed link, should be without www.

      posted in Home Assistant
      alowhum
      alowhum
    • RE: Modifying A0 value to Percentage

      Perhaps this code is of interest to you. It's the Candle plant health sensor. It's got all the bells and whistles you could want, including optional support for automated irrigation.

      One thing you'll notice in there is that the capacitive moisture sensors output voltages between 0 and 3. So in @rvendrame's code you may have to change the 1023 to 650, and also make sure no voltages higher than that would lead to percentages above 100%.

            int16_t moistureLevel = analogRead(analog_pins[i]);
            Serial.print(F("raw analog moisture value: "));
            Serial.println(moistureLevel);
      
            if( moistureLevel > 650 ){moistureLevel = 650;}
            moistureLevels[i] = map(moistureLevel,0,650,0,99); // The maximum voltage output of the capacitive sensor is 3V, so since we're measuring 0-5v about 614 is the theoretical highest value we'll ever get.
      

      I notice in your code that the title Analog Soil Moisture Sensorx3 is too long. It can't be longer than 25 characters.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Something's cooking in the MySensors labs...

      Wait, wait.. what is that USB stick with the dual antennas? Is that a dedicated MySensors gateway device?

      // Ah, it's project Janus. AWESOME!

      posted in Announcements
      alowhum
      alowhum
    • RE: NRF24L01+ and NRF24L01+PA-LNA problems - testing in progress

      What @wiredfrank said. Don't use these unshielded PA device in the first place.

      posted in Troubleshooting
      alowhum
      alowhum
    • Strange jumps in MH-Z18B CO2 sensor values

      I have a MH-Z19B CO2 sensor (as part of the Candle system).

      In the logs I see some strange sudden jumps between measured levels.

      mh-z19b_strange_jumpps.png

      I don't think it's an issue with the code.

      Could this be related to an internal re-calibration of the device somehow? Has anyone else seen something similar?

      Or maybe the sensor is just dying?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Best choise for a controller

      There are also some very cheap usb-stick size SSD's now. Now sure about the long term quality, but it's.. interesting.

      This 64Gb one is 15 dollars including shipping

      This 128Gb one is $20.

      Finally, this Kingdian one seems very popular. It's $30, but is a bit faster.

      posted in Controllers
      alowhum
      alowhum
    • RE: House renovation, how to a good electrical system oriented to MySensors?

      Thanks for the advice @skywatch! You're right about the distance increasing, for sure. Then again, if the voltage drops from 12v to, say, 10 volt, would that matter? The Arduino itself will still bring it down to 5, and it can handle anything between 6 and 12 as an input on the jack plug?

      What do you mean with running it in a loop? Where could I learn more about that?

      posted in Hardware
      alowhum
      alowhum
    • RE: MySensors Smart Watch

      Has anyone bought a PineTime by chance? They are really progressing quickly, with OTA support and everything.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Best choise for a controller

      @dzjr I had a look at your list, and as I read through it I realised that the Mozilla WebThings Gateway really needs P1 support. So I created an addon for that.

      It might make the Mozilla WebThings Gateway an option for you, although it doesn't support all the things you asked for (DMX, Modbus, APC USB).

      It does have great usability, privacy friendly local voice control, and of course MySensors support.

      posted in Controllers
      alowhum
      alowhum
    • RE: House renovation, how to a good electrical system oriented to MySensors?

      Thanks! Ethernet cable is a great idea (since it's also used for power over ethernet it makes sense). Unfortunately I've already been donated some speaker wire. It's gauge is larger than ethernet, and it's made of copper, so I think it should be ok.

      posted in Hardware
      alowhum
      alowhum
    • RE: House renovation, how to a good electrical system oriented to MySensors?

      Thanks. But my apartment is only 10 from front to back. I thought that if I place the power source in the middle, then the maximum distance to an endpoint is about 5 meters. The same as the maximum length of USB extension cords.

      Would you still recommend against it for those lengths?

      posted in Hardware
      alowhum
      alowhum
    • RE: Smartmeter sensors

      @sincze did you manage to create a nice sketch to read out a P1 device? I'm looking for such a sketch.

      posted in My Project
      alowhum
      alowhum
    • RE: House renovation, how to a good electrical system oriented to MySensors?

      I wanted to revive this topic, as I'm noticing this is becoming a little more common.

      If anyone would now build a second DC system in their home, how would you go about it?

      I get the sense that the industry is standardising on 48 volts for this. It's also a common output for photovoltaic systems, so you could connect a solar system quite easily.

      @bruno, what did you go for in the end?

      I've been donated a large spool of speaker wire, so I could retrofit something in my home. Since Arduino's can take 12v input voltage, I was thinking it would make things nice and simple if I used 12v. I could buy a PC power supply (Andres Spiess seems to dig those) and hook that up somethere in the middle.

      • Would a 12v system be a bad idea in a small city apartment? At what apartment size should 12v no longer be considered?
      • If many 12v devices share a wire, does that lead to any weird side effects?
      posted in Hardware
      alowhum
      alowhum
    • RE: What did you build today (Pictures) ?

      Man, things are starting to look very professional around here.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Suggestions for my setup? Very new here.

      Have a look at https://www.candesmarthome.com for a very privacy focussed MySensors based smart home solution

      posted in General Discussion
      alowhum
      alowhum
    • RE: [SOLVED] Go to loop(); when parent/gateway can't be found.

      I usualy have it set at 10000. Give the network some time to connect.

      posted in Development
      alowhum
      alowhum
    • RE: Best 3d printers

      Sorry to hear about your troubles. With my Ender I never have to adjust anything. It worked great out of the box and has continued to do so.

      Perhaps you could try moving the whole build plate up to a higher point, where the springs are more compressed? There are also people who replace the springs for stiffer versions. Maybe that could help here.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Weird protocol version mismatch

      I will, but it won't be for a while.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Weird protocol version mismatch

      Ah, thanks for the clarification. In my use case this wouldn't be a problem. Phew!

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Air quality sensors

      The plantower devices were nice and small. But in the end I settled on the SDS011 simply because it can be connected to without soldering. In my use case - making it accessible to beginners - that was the most important factor.

      I've also found that "how precise is it" doesn't matter all that much.

      • In a home you just want an indication. After a while you just start to think in about 5 levels, ranging from "bad" to ''great".
      • These cheap devices aren't precise enough to use in situations where you would care about precision, such as official measurements. So my recommendation is to forget about this.
      posted in Hardware
      alowhum
      alowhum
    • RE: Air quality sensors

      I'd love to hear your reviews on your sensors actually.

      I have an SDS011 fine dust sensor, couple of CO2 sensors (all the same unit) and a normal MQ gas leak sensor inside my heater.

      posted in Hardware
      alowhum
      alowhum
    • RE: Best 3d printers

      Go for the Ender. It has wide support. You'll love it. Later you can always sell it second hand - precisely because it's such a popular machine.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      This thread reads like an Agathie Christie novel. Well done on finding it!

      posted in Hardware
      alowhum
      alowhum
    • RE: Best 3d printers

      Of the Prusa i3, I read on the Dutch platform Tweakers.net that there are some safety aspects, so would the power supply not be fireproof?

      I haven't read that, but I haven't looked into the Prusa deeply. I bought the Ender 3 because of its price to performance ratio.

      I wondered if I should get the Ender 3 pro. The only thing it really added that I wanted is a better power supply. But since it doesn't really impact anything, and you can always upgrade later, I decided to go with the normal Ender.

      How did you mean the touch screen? do you mean that you actually have to replace the controller with a Raspberry pi?

      No, I mean that some 3D printers come with fancy touch screen interfaces. The way you normally use them is that you put a file on an SD card, put that SD card in the printer, and then use the on device interface to start the print.

      But you can also connect a Raspberry Pi to your printer (it has a USB port), and then it can control the printer. Once you do that, you can start, stop and follow prints through a web interface. No more hassle with SD cards. It's something you will want.

      I use a 10 euro Raspberry Pi Zero W for this.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      Look for something like MY_DEBUG_VERBOSE_NRF24 - something along those lines, for that debug option I mentioned.

      posted in Hardware
      alowhum
      alowhum
    • RE: Weird protocol version mismatch

      Darn, I was actually looking into the RFM69-directly-on-PI use case. Seems desirable enough to me?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      What happens if you remove everything but the essentials for your network here?

      #define MY_REPEATER_FEATURE
      #define MY_TRANSPORT_SANITY_CHECK
      #define MY_SIGNAL_REPORT_ENABLED
      #define MY_RF24_CE_PIN     9
      #define MY_RF24_CS_PIN     10
      #define MY_RF24_CHANNEL   29
      #define RF24_DATARATE      RF24_2MBPS
      #define RF24_PA_LEVEL      RF24_PA_MIN
      #define RF24_PA_LEVEL_GW   RF24_PA_MIN
      #define MY_NODE_ID         1
      #define MY_PARENT_NODE_ID  0
      #define MY_PARENT_NODE_IS_STATIC
      
      #define MY_TRANSPORT_WAIT_READY_MS 1
      

      Maybe only leave #define MY_RF24_CHANNEL 29?

      posted in Hardware
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      Is there a reason you're swapping your CE and CS pins?

      posted in Hardware
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      @Avamander said in Arduino Nanos don't work as nodes:

      Um, line 22 #include <MySensors.h>

      Ah, you're right. Have been programming in other languages lately, where that indicates a comment.

      posted in Hardware
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      Also, your code never loads MySensors? It's commented out?

      Your node code is very strange.

      posted in Hardware
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      pinMode(A7, INPUT); should not be in presentation. It should be in setup. Similarly, don't put Serial.begin(115200); in there. All that should be in presentation function is sendSketchInfo and present.

      Also, don't use "delay", use wait() instead.

      And where is your setup function in the first place?

      posted in Hardware
      alowhum
      alowhum
    • RE: [Solved] Arduino Nanos don't work as nodes

      I created a new gateway on an Arduino Nano today, and that worked. Not sure if that was using the very latest MySensors though. The rest of my network is all based on the RF-Nano, which I'm a big fan of. It shields me from exactly these types of issues 🙂

      How are you powering them?

      Tried an external 3.3V regulator

      The Nano itself runs on 5v, but I suspect you know that.

      Have you tried enabling the advanced radio debug option? (I forget it's name). That can magicaly enable things sometimes. At the very least it will tell you more about what's going on.

      Are you sure there's nothing like encrpytion on the gateway?

      Built three new boards to plug the radio and the Nano into -

      Have you tried replacing all the wires between the nano and the radio module?

      I recommend just buying the Arduino Nano Wireless Expansion Board. They cost a dollar on Aliexpress.

      Maybe you have some of those fake Atmel chips?

      posted in Hardware
      alowhum
      alowhum
    • RE: MySensors over Bluetooth ?

      Interesting. Would this automatically secure the communicatin?

      posted in General Discussion
      alowhum
      alowhum
    • MySensors over Bluetooth ?

      Looking at the BLE Nano and the new Bluetooth Arduino devices, I was wondering if the mysensors protocol could run on top of Bluetooth?

      Is it a crazy idea? Is it even technically possible? Could it, for example, extract away handling of encryption?

      posted in General Discussion
      alowhum
      alowhum
    • RE: Best 3d printers

      @dzjr have a look here:
      https://www.reddit.com/r/3Dprinting/comments/gdbu1o/purchase_advice_megathread_what_to_buy_who_to_buy/

      I think the 'consensus' is that these are the beginner printers to go for currently:

      Under $200
      Ender 3. It's recommended as a cheap beginners machine. This does not have any automation features though, such as automatic bed levelling, detecting if your fillament runs out, etc. Although you can add those if you want. It's also quite noisy.

      Above $200
      For a more hassle free experience I believe the Prusa i3 Mk3S is the recommended one to go for. It's more expensive of course, but you get a lot of that automation.

      It also depends on what material you want to print. Woodgrain filament cannot be used with the Ender's default extruder, for example, it will damage it. Something worth checking before purchase is it it can print flexible filament. That stuff is amazing! In general it seems ABS filament has become very unpopular.

      Don't worry too much about things like touch screens. You'll likely want to get a Raspberry Pi and install Octoprint on it. That way you can send prints to your printer and monitor its progress without having to babysit it. You don't want to be sitting next to those fumes and the noise all the time.

      Also don't worry about flexible removable magnetic printer beds. From what I can tell glass beds offer the best quality for things like PLA, which is what you'll most likely be printing in generally.

      Whatever you do, go for a printer that has a large community of users. If you go on websites like Thingiverse you'll immediately notice which printers are popular. If you look at the most popular new 3D print designs you'll currently find a lot of Ender specific creations.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Started with MySensors and about to give up (some feedback)

      Sounds great.

      This all reminds me of this post I made when I started out with MySensors. That was about how a lot of the example code used out of date sensors.

      posted in General Discussion
      alowhum
      alowhum
    • RE: Looking for recommendations, advice, and insights

      I'd have a look at Candle. Lots of people are building it, and it's based on MySensors.

      posted in General Discussion
      alowhum
      alowhum
    • PineTab as a MySensors smart home controller?

      The PineTab is a 10" linux tablet made by pine.org which will go on sale this month, for $75.

      In line with their other projects, the hardware and software are open source. So I've been thinking it could be a great startingpoint for creating a trustworthy alternative to the Google Home Hub.

      It could be used with MySensors in a number of ways.

      • The tablet has a built-in slot for expansino boards. One could be made that add MySensors radios (as well as other smart home radios).
      • Create a 'backpack' that replaces the rear cover, and add a radio module inside.
      • Similarly, create a stand. The tablet has pogopins on the side to which a keyboard cover can be connected. But this is essentially a USB 2.0 port, so it could also be used to connect it to something like this:

      pinetab_backpack.png

      I'm going to explore this idea as a next step for Candle. Would anyone else be interested in exploring this idea?

      posted in General Discussion
      alowhum
      alowhum
    • RE: Started with MySensors and about to give up (some feedback)

      I'm far from objective since I'm behind the project, but I think the easiest way to get started with MySensors is to use Candle. I've given a lot or workshops with it now, and it's getting to be quite good.

      • It uses Mozilla's WebThings Gateway, which is much more userfriendly than the other smart home controllers.
      • It offers voice control for all mysensors abilities.
      • The Candle Manager plugin allows you to upload code to Arduino's through a step by step wizard. It even allows you to make changes to the code in a wysiwyg manner. No need to install the Arduino IDE.

      Perhaps the guide could point to it as an option for absolute beginners?

      posted in General Discussion
      alowhum
      alowhum
    • RE: Best 3d printers

      @alowhum said in Best 3d printers:

      https://www.cnx-software.com/2019/04/22/zonestar-z6-entry-level-portable-3d-printer/

      I bought the Ender 3 (non-pro). It's my first 3D printer. So far it's great. I'm going to add an Mini E3 board to decrease the high-pitched noise from the stepper motors. I also bought a $9 3D Touch, a fake BLTouch, for auto bed levelling. Although it's not really needed? The bed has remained stable. Then I'll install that following this guide.

      I've also used a Pi Zero W I had lying around to install Octoprint. No more hassle with SD cards. There's even a plugin called "Spaghetti Detective" that uses machine learning to watch webcam images of your print being made. If your print goes wrong, it automatically stops it.

      posted in Enclosures / 3D Printing
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 1.0.8 was released a little while ago.

      A lot was rewritten under the hood.

      It also allows a serial device to also be a 'thing' itself. This is because the Candle Receiver implemented @mfalkvidd 's code to show transmission succes and error rate.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • X27 stepper motor that can be controlled from the Arduino directly

      Here is some code to manage an X27 stepper motor. These are commonly found behind a gauge in car dashboards.

      Because this type of stepper motor uses very little power, an Arduino can operate the stepper motor directly (video), by pulsing the coils.

      The idea is that it can act as a dashboard for certain values in the smart home.

      /*
       * DESCRIPTION
       * 
       * This device can toggle two relays, and thus two electric locks. These relays can be controlled via the Candle Controller, but also via SMS (if you want).
       * The SMS function is password protected: you have to send a password to switch the relay. Access can also be limited to only certain mobile phone numbers, and only certain moments (by toggling the Mobile control switch).
       * 
       * If you send an SMS without the password, it will be shown as the Incoming SMS. This can be used to automate other things in your home. For example, you could create a rule that when the system receices an SMS with "purifier on" in it, the air purifier will turn on.
       * 
       * This way you can control smart devices in your home even if it/Candle is not connected to the internet.
       * 
       * If data transmission is disabled, you can change the state of the lock via SMS or the pushbutton without the new state being sent to the controller.
       * 
       * SETTINGS */ 
      
      #define CLOCKWISE                                   // Rotate clockwise. As values increase, the indicator needle will move clockwise. To make the needle move counter clockwise as values increase, uncheck this.
      
      #define RF_NANO                                     // RF-Nano. Check this box if you are using the RF-Nano Arduino, which has a built in radio. The Candle project uses the RF-Nano.
      
      /* END OF SETTINGS
       *  
       *  
      */
      
      
      
      // Enable debug prints to serial monitor
      #define DEBUG
      //#define MY_DEBUG
      
      #define LOOP_DURATION 1000                          // The main loop runs every x milliseconds. This main loop starts the modem, and from then on periodically requests the password.
      #define SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION 120  // The smart lock might not send any data for a very long time if it isn't used. Sending a heartbeat tells the controller: I'm still there.
      
      
      
      #ifdef RF_NANO
      // If you are using an RF-Nano, you have to switch CE and CS pins.
      #define MY_RF24_CS_PIN 9                            // Used by the MySensors library.
      #define MY_RF24_CE_PIN 10                           // Used by the MySensors library.
      #endif
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL RF24_PA_MAX  
      //#define MY_RADIO_RFM69
      
      // Mysensors advanced settings
      #define MY_TRANSPORT_WAIT_READY_MS 10000            // Try connecting for 10 seconds. Otherwise just continue.
      //#define MY_RF24_CHANNEL 100                       // In EU the default channel 76 overlaps with wifi, so you could try using channel 100. But you will have to set this up on every device, and also on the controller.
      #define MY_RF24_DATARATE RF24_1MBPS                 // Slower datarate makes the network more stable
      //#define MY_RF24_DATARATE RF24_250KBPS             // Slower datarate increases wireless range
      //#define MY_NODE_ID 10                             // Giving a node a manual ID can in rare cases fix connection issues.
      //#define MY_PARENT_NODE_ID 0                       // Fixating the ID of the gatewaynode can in rare cases fix connection issues.
      //#define MY_PARENT_NODE_IS_STATIC                  // Used together with setting the parent node ID. Daking the controller ID static can in rare cases fix connection issues.
      #define MY_SPLASH_SCREEN_DISABLED                   // Saves a little memory.
      //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE      // Saves a little memory.
      
      // Mysensors security
      //#define DEBUG_SIGNING
      #define MY_ENCRYPTION_SIMPLE_PASSWD "changeme"     // Be aware, the length of the password has an effect on memory use.
      //#define MY_SECURITY_SIMPLE_PASSWD "changeme"      // Be aware, the length of the password has an effect on memory use.
      //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7         // Setting a pin to pickup random electromagnetic noise helps make encryption more secure.
      
      
      // Enable repeater functionality for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      #define ROTATION_CHILD_ID  3                        // Child ID for the actual rotation input
      #define LOWER_BOUNDARY_ID  4                        // Child ID for the lower boundary value. Starts as 0%
      #define UPPER_BOUNDARY_ID  5                        // Child ID for the upper boundary value. Starts as 100%
      
      
      #define RADIO_DELAY 100                             // Milliseconds delay betweeen radio signals. This gives the radio some breathing room.
      
      MyMessage percentage_message(ROTATION_CHILD_ID, V_PERCENTAGE); // A generic boolean state message.
      
      boolean send_all_values = 1;
      
      int percentage = 0;
      int previous_percentage = 0;
      int lower_boundary = 0;
      int upper_boundary = 100;
      
      
      // STEPPER
      #include <Stepper.h>
      #define  STEPS  720                                 // steps per revolution (limited to 315°)
      #define  STEPPER_1  3
      #define  STEPPER_2  4
      #define  STEPPER_3  5
      #define  STEPPER_4  6
      
      
      // create an instance of the stepper class:
      Stepper stepper(STEPS, STEPPER_1, STEPPER_2, STEPPER_3, STEPPER_4);
      
      int pos = 0;                                        //Position in steps(0-630)= (0°-315°)
      int val = 0;
      
      
      void before()
      {
        pinMode(STEPPER_1, OUTPUT);
        pinMode(STEPPER_2, OUTPUT);
        pinMode(STEPPER_3, OUTPUT);
        pinMode(STEPPER_4, OUTPUT);
      }
      
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo(F("Gauge"), F("1.0")); wait(RADIO_DELAY);
        present(ROTATION_CHILD_ID, S_DIMMER, F("Rotation") ); wait(RADIO_DELAY);
        present(LOWER_BOUNDARY_ID, S_DIMMER, F("Lower boundary") ); wait(RADIO_DELAY);
        present(UPPER_BOUNDARY_ID, S_DIMMER, F("Upper boundary") ); wait(RADIO_DELAY);
        
        send_all_values = true;                           // Whenever a new presentation is requested, we should also send the current values of the children.
      }
      
      
      void setup()
      {
        Serial.begin(115200);
        Serial.println(F("Hello world, I am gauge."));
      
        stepper.setSpeed(30);    // set the motor speed to 30 RPM (360 PPS aprox.).
        stepper.step(630);       // Reset Position(630 steps counter-clockwise). 
      
      
        if( loadState(LOWER_BOUNDARY_ID) <= 100 ){
          lower_boundary = loadState(LOWER_BOUNDARY_ID);
          Serial.print(F("Loaded lower boundary from eeprom: ")); Serial.println(lower_boundary);
        }
        if( loadState(UPPER_BOUNDARY_ID) <= 100 ){
          
          upper_boundary = loadState(UPPER_BOUNDARY_ID);
          Serial.print(F("Loaded upper boundary from eeprom: ")); Serial.println(upper_boundary);
        }
      
        //percentage = loadState(ROTATION_CHILD_ID);
        //if( percentage > 100 ){ percentage = 100; }
        //if( percentage < 0 ){ percentage = 0; } // not really possible
      
        //Serial.println(F("Sending initial percentage"));
        //send(percentage_message.setSensor(ROTATION_CHILD_ID).set(percentage),1); wait(RADIO_DELAY); // Send initial state
      }
      
      void send_values()
      {
      #ifdef DEBUG
        Serial.println(F("Sending values and states"));
      #endif
        send(percentage_message.setSensor(ROTATION_CHILD_ID).set(percentage)); wait(RADIO_DELAY); // Send initial state
        send(percentage_message.setSensor(LOWER_BOUNDARY_ID).set(lower_boundary)); wait(RADIO_DELAY); // Send initial state
        send(percentage_message.setSensor(UPPER_BOUNDARY_ID).set(upper_boundary)); wait(RADIO_DELAY); // Send initial state
      
        send_all_values = 0;
      }
      
      
      void loop()
      {
        if( send_all_values ){
      #ifdef DEBUG
          Serial.println(F("RESENDING VALUES"));
      #endif
          send_values();
        }
      
      
      
        if( percentage != previous_percentage ){
          previous_percentage = percentage;
          Serial.print(F("Percentage changed to: ")); Serial.println(percentage);
          send(percentage_message.setSensor(ROTATION_CHILD_ID).set(percentage)); // Send on state
          //saveState(ROTATION_CHILD_ID, percentage);
      
      #ifdef CLOCKWISE
          val = map(percentage,lower_boundary,upper_boundary,0,630);    // map pot range in the stepper range.
      #else
          val = map(percentage,lower_boundary,upper_boundary,630,0);    // map pot range in the stepper range.
      #endif
      
          
          Serial.print(F("New val: "));
          Serial.println( val );
          //wait(500);
        }
      
      
      
        // Move the stepper needle
        if( abs(val - pos) > 2 ){         // if difference is greater than 2 steps.
            if( (val - pos) > 0 ){
                stepper.step(-1);      // move one step to the left.
                pos++;
                }
            if((val - pos) < 0){
                stepper.step(1);       // move one step to the right.
                pos--;
                }
            }
      
      
      
      
      
      
        static unsigned long last_loop_time = 0;          // Holds the last time the main loop ran.
        static byte loop_counter = 0;                     // Count how many loops have passed (reset to 0 after at most 254 loops).
      
        if( millis() - last_loop_time > LOOP_DURATION ){  // Runs every second
          last_loop_time = millis();
          loop_counter++;
          
          wdt_reset();                                    // Reset the watchdog timer. If this doesn't happen, the device must have crashed, and it will be automatically rebooted by the watchdog.
      
          if( loop_counter >= SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION ){ // If a couple of minutes have passed, tell the controller we're still here
            loop_counter = 0;
      #ifdef DEBUG
            Serial.println(F("Sending heartbeat"));
      #endif
            sendHeartbeat();
          }
        }
      }
      
      
      
      void receive(const MyMessage &message)
      {
        Serial.print(F(">> Incoming message of type ")); Serial.print(message.type);
        Serial.print(F(" for child:")); Serial.println(message.sensor);
        
        if( message.isAck() ){
      #ifdef DEBUG
          Serial.println(F("- Echo"));
      #endif
        }
        else if( message.sensor==ROTATION_CHILD_ID ){
          percentage = message.getInt();
      
          //Serial.print(", type:");
          //Serial.print(message.type);    
          //Serial.print(", New value: ");
          //Serial.println( percentage );
          
        }
        else if( message.sensor==LOWER_BOUNDARY_ID ){                // We only expect one type of message from controller. But we better check anyway.
          lower_boundary = message.getInt();
          saveState(LOWER_BOUNDARY_ID, lower_boundary);
        }
        else if( message.sensor==UPPER_BOUNDARY_ID ){                // We only expect one type of message from controller. But we better check anyway.
          upper_boundary = message.getInt();
          saveState(UPPER_BOUNDARY_ID, upper_boundary);
        }
      }
      
      
      
      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       * 
       */
      

      During my testing I noticed that at a certain time the Arduino Nano's USB chip stopped working, so I suspect there is too much kickback from the stepper anyway. Turns out the USB cable broke. It still works fine.

      In theory there's a library out there that works better than using the standard stepper library. But I wasn't able to find it. There is a library for the X25 that might work, but I haven't tried it. But I haven't gotten it to work properly.

      As an alternative, you could use normal small servo's that the Arduino can also operate without requiring a motor control chip. But that's a lot more noisy. It does have a lot more power though.

      I put the code here in case someone wants to play around with it. For those interested, there is also an open source board to make these gauges more robust by adding protective diodes.

      posted in My Project
      alowhum
      alowhum
    • RE: Moisture sensing + relay. Please help with software.

      Here is some code that does exactly what was asked for:
      https://github.com/createcandle/Devices/tree/master/Plant_health

      posted in Troubleshooting
      alowhum
      alowhum
    • Receiver that creates details about data transmission errors

      Based on the example code by @mfalkvidd I created a USB serial receiver that outputs data about network errors.

      mysensors_network_errors.png
      The top line shows the good transmissions, the bottom one shows the bad ones.

      candle_receiver_issues_close_up.png
      Close-up

      I was surprised to see so many errors.

      • What could this be?
      • How could I find out what is causing this?

      Also, how can I understand these values? Does a transmission error mean that an incoming message failed? Or an outgoing message? How does MySensors determine what an error is? Does an error mean the transmissions totally failed? because in practize the network seems to be ok.

      For those interested, here's my full code:

      * 
      * The Candle receiver acts as the bridge between the Candle devices and the Candle Controller. 
      * 
      * It only allows communication with other Candle devices that use the same encryption password as it uses itself. 
      * When you install the Candle Manager, a random password is generated for you. If you ever want to change the encryption password used by your network, this can be done in the Candle Manager settings. 
      * Be warned that you will have to re-create this receiver as well as all your devices, since they will all need to have new code with the new password in it.
      * 
      * If you have already installed the MySensors add-on, please temporarily disable it before creating this receiver. Otherwise the MySensors add-on may try to connect to it during the creation process, and thus disrupt it.
      * 
      *
      * SETTINGS */ 
      
      // You can enable and disable the settings below by adding or removing double slashes ( // ) in front of a line.
      
      //#define RF_NANO                                     // RF-Nano. Enable this if you are using the RF-Nano Arduino, which has a built in radio. The Candle project uses the RF-Nano.
      
      #define SHOW_TRANSMISSION_DETAILS                   // Show transmission details. If you enable this, the receiver will show you details about how many good transmission are made, as well as any transmission errors. This is updated every 5 minutes.
      
      /* END OF SETTINGS
      *
      *
      *
      */
      
      
      // Enable MySensors debug output to the serial monitor, so you can check if the radio is working ok.
      //#define MY_DEBUG 
      
      #ifdef RF_NANO
      // If you are using an RF-Nano, you have to switch CE and CS pins.
      #define MY_RF24_CS_PIN 9                            // Used by the MySensors library.
      #define MY_RF24_CE_PIN 10                           // Used by the MySensors library.
      #endif
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24                               // MySensors supports multiple radio modules. Candle uses NRF24.
      //#define MY_RADIO_NRF5_ESB
      //#define MY_RADIO_RFM69
      //#define MY_RADIO_RFM95
      
      // Set LOW transmit power level as default, if you have an amplified NRF-module and
      // power your radio separately with a good regulator you can turn up PA level.
      //#define MY_RF24_PA_LEVEL RF24_PA_MIN
      //#define MY_RF24_PA_LEVEL RF24_PA_LOW
      //#define MY_RF24_PA_LEVEL RF24_PA_HIGH
      #define MY_RF24_PA_LEVEL RF24_PA_MAX                // Sets the radio to transmit at maximum power, for optimum range.
      
      // Mysensors advanced security
      #define MY_ENCRYPTION_SIMPLE_PASSWD "changeme"      // The Candle Manager add-on will change this into the actual password your network uses.
      //#define MY_SECURITY_SIMPLE_PASSWD "changeme"      // Be aware, the length of the password has an effect on memory use.
      //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7         // Setting a pin to pickup random electromagnetic noise helps make encryption more secure.
      
      // Mysensors advanced settings
      //#define MY_RF24_CHANNEL 100                       // In EU the default channel 76 overlaps with wifi, so you could try using channel 100. But you will have to set this up on every device, and also on the controller. You can even try 115.
      //#define MY_RF24_DATARATE RF24_250KBPS             // Slower datarate increases the range, but the RF-Nano does not support this slow speed.
      #define MY_RF24_DATARATE RF24_1MBPS                 // This datarate is supported by pretty much all NRF24 radios, including the RF-Nano.
      #define MY_SPLASH_SCREEN_DISABLED                   // Saves a little memory.
      
      // Enable serial gateway
      #define MY_GATEWAY_SERIAL                           // This is the main function of this code. It tells the MySensors library to turn this device into a gateway/receiver for MySensors network.
      
      
      #ifdef SHOW_TRANSMISSION_DETAILS
      // Report how often there are wireless communication issues
      #define MY_INDICATION_HANDLER
      unsigned int txOK = 0;                              // Good transmissions counter
      unsigned int txERR = 0;                             // Failed transmissions counter
      #define REPORT_INTERVAL 300000                      // Report every 5 minutes
      #define CHILD_ID_TX_OK 1                            // Child id for the counter of OK transmissions
      #define CHILD_ID_TX_ERR 2                           // Child id for the counter of failed transmissions
      #endif
      
      
      #include <MySensors.h>                              // The MySensors library, which takes care of creating the wireless network.
      #include <avr/wdt.h>                                // The watchdog timer - if the device becomes unresponsive and doesn't periodically reset the timer, then it will automatically reset once the timer reaches 0.
      
      // Clock for the watchdog
      #define INTERVAL 500                                // Every second we reset the watchdog timer. If the device freezes, the watchdog will not be reset, and the device will reboot.
      #define RADIO_DELAY 100                             // Milliseconds of delay between sending transmissions, this keeps the radio module happy.
      
      
      unsigned long current_time = 0;
      
      
      
      #ifdef SHOW_TRANSMISSION_DETAILS
      
      
      MyMessage transmission_quality_message(CHILD_ID_TX_OK, V_CUSTOM);
      
      void indication(indication_t ind)
      {
        switch (ind)
        {
          case INDICATION_TX:
            txOK++;
            break;
          case INDICATION_ERR_TX:
            txERR++;
            break;
        }
      }
      #endif
      
      
      
      void presentation()
      {
      #ifdef SHOW_TRANSMISSION_DETAILS
        sendSketchInfo(F("Candle receiver"), F("1.0"));
        present(CHILD_ID_TX_OK, S_CUSTOM, F("Good transmissions")); // Tell the controller about this property
        present(CHILD_ID_TX_ERR, S_CUSTOM,F("Bad transmissions")); // Tell the controller about this property
      #endif
      }
      
      
      
      void setup()
      {
        //Serial.println(F("Hello, I am a Candle receiver"));
      
        send(transmission_quality_message.setSensor(CHILD_ID_TX_OK).set(txOK)); // Send the good transmissions value
        send(transmission_quality_message.setSensor(CHILD_ID_TX_ERR).set(txERR)); // Send the failed transmissions value
      
        wdt_enable(WDTO_2S);                              // Starts the watchdog timer. If it is not reset at least once every 2 seconds, then the entire device will automatically restart.                                 
      }
      
      
      
      void loop()
      {
        static unsigned long previous_millis = 0;         // Used to run the internal clock
        current_time = millis();
        
        if( current_time - previous_millis >= INTERVAL ){ // Main loop, runs every second.
          previous_millis = current_time;                 // Store the current time as the previous measurement start time.
          wdt_reset();                                    // Reset the watchdog timer
          sendHeartbeat();                                // Tell the controller we're still connected.
        }
      
      #ifdef SHOW_TRANSMISSION_DETAILS
        static unsigned long last_send = 0;
        if( current_time - last_send >= REPORT_INTERVAL ){
          send(transmission_quality_message.setSensor(CHILD_ID_TX_OK).set(txOK)); // Send the good transmissions value
          send(transmission_quality_message.setSensor(CHILD_ID_TX_ERR).set(txERR)); // Send the failed transmissions value
          txOK = 0;                                       // Reset the good transmissions counter back to 0
          txERR = 0;                                      // Reset the error transmissions counter back to 0
          last_send = current_time;                       // Remember the time when the transmissions was done.
        }
      #endif
      
      }
      
      
      /**
      * The MySensors Arduino library handles the wireless radio link and protocol
      * between your home built sensors/actuators and HA controller of choice.
      * The sensors forms a self healing radio network with optional repeaters. Each
      * repeater and gateway builds a routing tables in EEPROM which keeps track of the
      * network topology allowing messages to be routed to nodes.
      *
      * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
      * Copyright (C) 2013-2018 Sensnology AB
      * Full contributor list: https://github.com/mysensors/MySensors/graphs/contributors
      *
      * Documentation: http://www.mysensors.org
      * Support Forum: http://forum.mysensors.org
      *
      * This program is free software; you can redistribute it and/or
      * modify it under the terms of the GNU General Public License
      * version 2 as published by the Free Software Foundation.
      */
      
      
      posted in General Discussion
      alowhum
      alowhum
    • RE: RF Nano = Nano + NRF24, for just $3,50 on Aliexpress

      @torfinn These settings should make it work, regardless of which version you buy:

      // If you are using an RF-Nano, you have to switch CE and CS pins.
      #define MY_RF24_CS_PIN 9                            // Used by the MySensors library.
      #define MY_RF24_CE_PIN 10                           // Used by the MySensors library.
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL RF24_PA_MAX
      
      // Mysensors advanced settings
      #define MY_RF24_DATARATE RF24_1MBPS                 // This datarate is supported by pretty much all NRF24 radios, including the RF-Nano.
      
      
      posted in Hardware
      alowhum
      alowhum
    • RE: Anyone tried the stc15l204? It appears to be an inexpensive integrated mcu + NRF24L01+

      It's not a perfect pin-out match. You should definitely check out this thread:
      https://forum.mysensors.org/topic/10327/rf-nano-nano-nrf24-for-just-3-50-on-aliexpress/1

      But you're right, it's great for beginners. That's why it forms the basis of the Candle project.

      posted in Hardware
      alowhum
      alowhum
    • RE: Anyone tried the stc15l204? It appears to be an inexpensive integrated mcu + NRF24L01+

      The RF-Nano may be what you're looking for? It's an inexpensive Nano with built in NRF24.

      posted in Hardware
      alowhum
      alowhum
    • RE: !MCO:PRO:RC=1 in debug logs

      Ah, interesting, thanks for the explanation.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Relay Actuator with momentary (pulse) action

      Here is my code, which I used to hack my dishwasher so I can turn it on via my smart home system. The code is designed to work well with the Mozilla WebThings gateway and the Candle project, which is based on MySensors. But it but should work just fine with any smart home controller that supports MySensors.

      /**
       * The MySensors Arduino library handles the wireless radio link and protocol
       * between your home built sensors/actuators and HA controller of choice.
       * The sensors forms a self healing radio network with optional repeaters. Each
       * repeater and gateway builds a routing tables in EEPROM which keeps track of the
       * network topology allowing messages to be routed to nodes.
       *
       * Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
       * Copyright (C) 2013-2015 Sensnology AB
       * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
       *
       * Documentation: http://www.mysensors.org
       * Support Forum: http://forum.mysensors.org
       *
       * This program is free software; you can redistribute it and/or
       * modify it under the terms of the GNU General Public License
       * version 2 as published by the Free Software Foundation.
       *
       *******************************
       *
       * REVISION HISTORY
       * Version 1.0 - Henrik Ekblad
       *
       * DESCRIPTION
       * Example sketch showing how to control physical relays.
       * This example will remember relay state after power failure.
       * http://www.mysensors.org/build/relay
       * 
       * 
       * 
       * Only sends a quick pulse via a relay. Useful to hack other devices with push 
       * buttons. In my case, a cheap IKEA dishwasher that didn't have a timer functionality.
       */
      
      // Enable debug prints to serial monitor
      #define DEBUG
      #define MY_DEBUG
      
      #define LOOP_DURATION 1000                          // The main loop runs every x milliseconds. This main loop starts the modem, and from then on periodically requests the password.
      #define SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION 120  // The smart lock might not send any data for a very long time if it isn't used. Sending a heartbeat tells the controller: I'm still there.
      
      //#define RF_NANO                                     // RF-Nano. Check this box if you are using the RF-Nano Arduino, which has a built in radio. The Candle project uses the RF-Nano.
      
      
      
      
      #ifdef RF_NANO
      // If you are using an RF-Nano, you have to switch CE and CS pins.
      #define MY_RF24_CS_PIN 9                            // Used by the MySensors library.
      #define MY_RF24_CE_PIN 10                           // Used by the MySensors library.
      #endif
      
      // Enable and select radio type attached
      #define MY_RADIO_RF24
      #define MY_RF24_PA_LEVEL RF24_PA_MAX  
      //#define MY_RADIO_RFM69
      
      // Mysensors advanced settings
      #define MY_TRANSPORT_WAIT_READY_MS 10000            // Try connecting for 10 seconds. Otherwise just continue.
      //#define MY_RF24_CHANNEL 100                       // In EU the default channel 76 overlaps with wifi, so you could try using channel 100. But you will have to set this up on every device, and also on the controller.
      //#define MY_RF24_DATARATE RF24_1MBPS                 // Slower datarate makes the network more stable
      //#define MY_RF24_DATARATE RF24_250KBPS             // Slower datarate increases wireless range
      //#define MY_NODE_ID 10                             // Giving a node a manual ID can in rare cases fix connection issues.
      //#define MY_PARENT_NODE_ID 0                       // Fixating the ID of the gatewaynode can in rare cases fix connection issues.
      //#define MY_PARENT_NODE_IS_STATIC                  // Used together with setting the parent node ID. Daking the controller ID static can in rare cases fix connection issues.
      #define MY_SPLASH_SCREEN_DISABLED                   // Saves a little memory.
      //#define MY_DISABLE_RAM_ROUTING_TABLE_FEATURE      // Saves a little memory.
      
      // Mysensors security
      //#define DEBUG_SIGNING
      //#define MY_ENCRYPTION_SIMPLE_PASSWD "changeme"      // Be aware, the length of the password has an effect on memory use.
      //#define MY_SECURITY_SIMPLE_PASSWD "changeme"      // Be aware, the length of the password has an effect on memory use.
      //#define MY_SIGNING_SOFT_RANDOMSEED_PIN A7         // Setting a pin to pickup random electromagnetic noise helps make encryption more secure.
      
      
      // Enable repeater functionality for this node
      //#define MY_REPEATER_FEATURE
      
      #include <MySensors.h>
      
      #define RELAY_1  3  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
      #define NUMBER_OF_RELAYS 1 // Total number of attached relays
      #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
      #define PULSELENGTH 500 // How long the pulse should last (how long the button should be pressed).
      #define RADIO_DELAY 100                             // Milliseconds delay betweeen radio signals. This gives the radio some breathing room.
      
      MyMessage relay_message(RELAY_1, V_STATUS); // A generic boolean state message.
      
      
      boolean desiredState = false;
      boolean send_all_values = 1;
      
      
      void before()
      {
        pinMode(RELAY_1, OUTPUT);
      	digitalWrite(RELAY_1, LOW);
      }
      
      void presentation()
      {
      	// Send the sketch version information to the gateway and Controller
      	sendSketchInfo(F("Dish washer"), F("1.0")); wait(RADIO_DELAY);
        present(RELAY_1, S_BINARY, F("Power") ); wait(RADIO_DELAY);
        
        send_all_values = true;                           // Whenever a new presentation is requested, we should also send the current values of the children.
      }
      
      void setup()
      {
        Serial.begin(115200);
        Serial.println(F("Hello world, I am a relay."));
      }
      
      void send_values()
      {
      #ifdef DEBUG
        Serial.println(F("Sending button states"));
      #endif
        send(relay_message.set(desiredState)); wait(RADIO_DELAY); // Send initial state
      }
      
      
      void loop()
      {
        if( send_all_values ){
      #ifdef DEBUG
          Serial.println(F("RESENDING VALUES"));
      #endif
          send_all_values = 0;
          send_values();
        }
      
      
      
        // Pulse the relay
        if(desiredState == 1){
          digitalWrite(RELAY_1, RELAY_ON);
          Serial.println(F("Turning on"));
          wait(PULSELENGTH);
          digitalWrite(RELAY_1, RELAY_OFF);
          Serial.println(F("Turned off"));
          
          desiredState = 0;
          send(relay_message.setSensor(RELAY_1).set(desiredState)); // Send off state
        }
      
      
      
        static unsigned long last_loop_time = 0;          // Holds the last time the main loop ran.
        static byte loop_counter = 0;                     // Count how many loops have passed (reset to 0 after at most 254 loops).
      
        if( millis() - last_loop_time > LOOP_DURATION ){ // Runs every second
          last_loop_time = millis();
      
          wdt_reset();                                  // Reset the watchdog timer. If this doesn't happen, the device must have crashed, and it will be automatically rebooted by the watchdog.
      
          if( loop_counter >= SECONDS_BETWEEN_HEARTBEAT_TRANSMISSION ){ // If a couple of minutes have passed, tell the controller we're still here
            loop_counter = 0;
            Serial.println(F("Sending heartbeat"));
            sendHeartbeat();
          }
        }
      
      }
      
      void receive(const MyMessage &message)
      {
        if( message.isAck() ){
      #ifdef DEBUG
          Serial.println(F("- Echo"));
      #endif
        }
        else if (message.type==V_STATUS) { // We only expect one type of message from controller. But we better check anyway.
      
          Serial.print("Incoming change for child:");
          Serial.print(message.sensor);
          Serial.print(", New status: ");
          Serial.println(message.getBool());
      
          // Change relay state
          desiredState = message.getBool(); //?RELAY_ON:RELAY_OFF;
          send(relay_message.setSensor(message.sensor).set(desiredState)); // Send on state
        }
      }
      
      posted in Troubleshooting
      alowhum
      alowhum
    • RE: !MCO:PRO:RC=1 in debug logs

      Yes, that was it. I love it when I answer my own questions 🙂

      posted in Troubleshooting
      alowhum
      alowhum
    • !MCO:PRO:RC=1 in debug logs

      When enabling MyDebug on a node I'm working on, I sometimes see bursts of this:

      
      100776 !MCO:WAI:RC=1
      100780 !MCO:PRO:RC=1
      100782 !MCO:PRO:RC=1
      100784 !MCO:PRO:RC=1
      100786 !MCO:PRO:RC=1
      100788 !MCO:PRO:RC=1
      100790 !MCO:PRO:RC=1
      100792 !MCO:PRO:RC=1
      100794 !MCO:PRO:RC=1
      100796 !MCO:PRO:RC=1
      100798 !MCO:PRO:RC=1
      100800 !MCO:PRO:RC=1
      100802 !MCO:PRO:RC=1
      100804 !MCO:PRO:RC=1
      100806 !MCO:PRO:RC=1
      100808 !MCO:PRO:RC=1
      100810 !MCO:PRO:RC=1
      100812 !MCO:PRO:RC=1
      100814 !MCO:PRO:RC=1
      100816 !MCO:PRO:RC=1
      100818 !MCO:PRO:RC=1
      100820 !MCO:PRO:RC=1
      100823 !MCO:PRO:RC=1
      100825 !MCO:PRO:RC=1
      100827 !MCO:PRO:RC=1
      100829 !MCO:PRO:RC=1
      100831 !MCO:PRO:RC=1
      100833 !MCO:PRO:RC=1
      100835 !MCO:PRO:RC=1
      100837 !MCO:PRO:RC=1
      100840 !MCO:PRO:RC=1
      ...etc...
      102779 !MCO:PRO:RC=1
      
      
      

      I don't see anything about this on the forum. I did find that MCO means "MySensors core".

      It seems to happen during the wait part of the code below, which is in the receive function:

          // Change relay state
          desiredState = message.getBool()?RELAY_ON:RELAY_OFF;
          if(desiredState == RELAY_ON){
            send(relay_message.setSensor(message.sensor).set(RELAY_ON)); // Send on state
            digitalWrite(RELAY_1, RELAY_ON);
            Serial.println(F("Turning on"));
            wait(PULSELENGTH);
            digitalWrite(RELAY_1, RELAY_OFF);
            Serial.println(F("Turned off"));
            //send(relay_message.setSensor(message.sensor).set(RELAY_OFF)); // Send off state
          }
          send(relay_message.setSensor(message.sensor).set(RELAY_OFF)); // Send off state
      	}
      

      Perhaps I should keep the receive function as brief as possible?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      Ah, so that's it!

      So then is MySensors a special case? How is it possible that #defines in the sketch work for MySensors?

      posted in Development
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 1.0.6 is up now. Like 1.0.5 it's a bugfix release.

      1.0.5

      • Fixed a bug that caused the WebThings Gateway to forget capability preferences.

      1.0.6.

      • It turned out that strings could lose leading zero's because they went through a function designed to remove zero's from floats. This impacted the Candle smart lock if users wanted to set a phone number that didn't start with a +.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      @electrik I'll have to test that. But there is only one file in my project, so..

      @Yveaux I tried that too (well, 256 and 128), but no effect.

      The full code (with built in software serial..) is now on Github:
      https://github.com/createcandle/Devices/blob/master/Smart_lock/Smart_lock.ino

      posted in Development
      alowhum
      alowhum
    • RE: Handling NACKs

      Ah, now I see. Thanks!

      posted in Development
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      Perhaps the define is used in another place somewhere in your project also

      I explored that too, but it's really not. It's all a one-file sketch.

      I have now embedded the entire software serial code in my code. It works now, even though it's unsightly.

      This hasn't been cleaned, but it might be interesting. It's upgraded code for the Candle Smart Lock, which can also be triggered via SMS (and this feature can be toggled).

      Apparently the code is too long to post
      
      posted in Development
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      @scalz Yes, you're right. That was how I had it originally (similar to how it works with mySensors), but that also doesn't work.

      posted in Development
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      I checked the IDE, and it also has the correct code:

      #ifndef _SS_MAX_RX_BUFF
      #define _SS_MAX_RX_BUFF 64 // RX buffer size
      #endif
      

      If I print out the value of _SS_MAX_RX_BUFF in the setup, then it shows the increased value.

      What could be causing this?

      posted in Development
      alowhum
      alowhum
    • RE: Expanding the size of an existing array?

      Trying some things.

      #include <SoftwareSerial.h>
      char SoftwareSerial::_receive_buffer[255];
      

      Results in error: conflicting declaration

      Strange, looking at the official code, it should support user overrides of this value.

      posted in Development
      alowhum
      alowhum
    • RE: Handling NACKs

      Very cool stuff.

      @mfalkvidd Would it be possible to create the functionality, but to measure the successrate of outgoing messages from the gateway node?

      For example, I'l love to be able to see how often the controller/gateway tries to toggle a distant node, but fails.

      posted in Development
      alowhum
      alowhum
    • Expanding the size of an existing array?

      After a lot of pulling hairs, I realised that the SoftwareSerial library has a hard coded 64 byte RX buffer.

      I originally thought I could do something like:

      #define _SS_MAX_RX_BUFF 255                         // Override the define to increase the buffer size
      #include <SoftwareSerial.h>                                // Load the library code
      SoftwareSerial softSerial1(GSM_RECEIVE_PIN,GSM_TRANSMIT_PIN); // Create the software serial object, hopefully with a bigger than normal buffer
      

      (updated the code to reflect that the #define came first)

      I assumed that other libraries would work like MySensors, and I could override this value. But it seems this override doesn't work.

      Now I could hardcode the bigger size into the library. But I was wondering: is there a way to do this without modifying the library code itself? Can I, for example, increase the size of the buffer after it's been created somehow?

      posted in Development
      alowhum
      alowhum
    • RE: wristwatches that invite development

      Honest question: are devices that 'open' allowed to be sold?

      posted in General Discussion
      alowhum
      alowhum
    • Candle won a Dutch National Privacy Award

      I'm proud to say that Candle, the privacy friendly smart home project that's based on MySensors, has won a Dutch National Privacy Award.

      I just wanted to say it literally wasn't possible without all your help, patience, and of course the large amount of open source code that Candle could build upon.

      Thanks everyone!

      privacy_award_mini_exhibit.jpg

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Looking for very simple rocker switch

      @Nca78 said in Looking for very simple rocker switch:

      So huge that the pins are in fact way too big (0.8*1.2mm section) to fit on a breadboard or in a Dupont connector

      Hahaha, that's hilarious 😄

      Thanks for trying though, really appreciate it!

      posted in Hardware
      alowhum
      alowhum
    • RE: Everything nRF52840

      From what I heard Pine was thinking about upgrading the watch to the NRF52840?

      posted in Hardware
      alowhum
      alowhum
    • RE: Candle - signal Hub - A universal 433Mhz signal detector and cloner

      Go for it! I don't see why it wouldn't be possible.

      posted in My Project
      alowhum
      alowhum
    • RE: What did you build today (Pictures) ?

      Wow. All these recent creations are so professional. Really nice!

      posted in General Discussion
      alowhum
      alowhum
    • RE: MySensors 2.3.2 released

      Thanks @tekka, that's a load off my mind 🙂

      Is there a way to use #define based on the version of the library?

      posted in Announcements
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @badmannen I'd love that feature too, but for now I think it will have to wait until Mozilla implements per-device settings.

      Meanwhile, a new version of the add-on (1.0.2) should be available soon.

      • Added MQTT topics support
      • Cloning can now be better controlled: child ID's above 100 will be cloned out into new things.
      • Better support for S_Power's V_Types.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensors 2.3.2 released

      Ok, but practically: I have a lot of Candle users whose version of MySensors will auto-update. But the code they will be uploading still has:

        if( message.isAck() ){
          Serial.println(F("-Got echo"));
          return;
        }
      

      So.. I should quickly change the code to also accomodate Echo. The question is: how?

      Will this work?

        if( message.isAck() || message.isEcho()){
          Serial.println(F("-Got echo"));
          return;
        }
      
      posted in Announcements
      alowhum
      alowhum
    • RE: MySensors 2.3.2 released

      2.4 will come with a set of new features some of you have been waiting for... stay tuned

      Exciting! Next Christmas? 🙂

      Practically: will code that uses ACK still work ok? I believe the answer was 'no' earlier, but I want to make sure.

      posted in Announcements
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      @Sergio-Rius You're right, it requires physical access. That makes it much less of a risk.

      There are other examples where wireless access was compromised though, such as the krakk attack.

      If a company created a new ideal device for mys and this device would be easily hacked, would not mean that mys is the culprit or bad.

      I don't think anyone is saying WiFi is without virtue. It's just a risk when deployed in IoT devices.

      Let's be honest: most vendors use WiFi out of convenience. Both for the end user, and for them. Devices that use WiFi are the logical choice if you want to send data to the cloud directly without any pesky smart home controller acting as a potential gatekeeper and privacy protector. At best, using WiFi is lazy or uncritical design. At its worst, WiFi is the technology of choice if your businessmodel depends on the extraction of data.

      posted in General Discussion
      alowhum
      alowhum
    • RE: GUIDE - NRF5 / NRF51 / NRF52 for beginners

      @martinc said in GUIDE - NRF5 / NRF51 / NRF52 for beginners:

      Hi,

      Is it possible to get Serial output in Arduino IDE for nRF52 boards with J-Link OB 7.0? Or do I need a newer programmer? Or maybe I can get it with ST-Link v2/v2.1 somehow?

      The answer is actually in the first post.

      posted in Development
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      self-contained systems with cellular links back to the cloud start to look pretty secure

      @neverdie: indeed, that's why the Candle smart lock has a built in GSM modem: to circumvent using the internet, while still allowing you to unlock the door when away from home. Of course, data should never be stored in the cloud.

      I'm guessing that even just regular browsing is higher risk than some hacker invading through your home automation

      Both are high risk, so I would avoid the trap of 'whataboutism'. Protecting a browser (using add-ons) is at least somewhat possible for end-users. As your ESP32 hack points out, when a hardware device is compromised, most people are completely at the mercy of the supplier.

      Basically, it's all about keeping a minimal attack surface:

      • Don't use IP based connectivity when zigbee/bluetooth/etc will do.
      • Don't use ARM chips when a simple Arduino will do.
      • Don't connect to the cloud unless you absolutely have to
      • Don't store data in the cloud unless you absolutely have to.
      posted in General Discussion
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      @scalz @Sergio-Rius

      I get your point, but the problem is very often mothers are not able to secure their LAN too

      True. That's why I'm not against WiFi, I'm against any IP-based technology for IoT devices. Which is ironic, since I'm a big fan of the Mozilla WebThings Gateway, a project whose main goal is to connect all kinds of devices to the internet using an open standard. I totally disagree with that goal 🙂

      mysensors only works bc it's not widely used

      True. I use MySensors for prototyping, but if the Candle project would ever turn into actual commercial devices, I'd probably move the wireless technology to Zigbee/Z-Wave/Bluetooth.

      So the overall point is that I much prefer network technologies that have smart devices on a separate, dedicated IoT network by design. Because it's separated by design, it means my mom is also better protected, by design.

      Then there's another point: these wifi modules have, or are connected to, ARM chips. These powerful chips are way more attractive to malicious parties than an Arduino Nano. That's why I follow the principle of "minimal viable hardware" when I design IoT devices.

      posted in General Discussion
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      Start learning about vlans, network segregation, AP mesh and redundancy.

      The thing is.. my mom doesn't know how to do that. In the real world, using WiFi is just asking for trouble.

      posted in General Discussion
      alowhum
      alowhum
    • RE: WI-FI IOT modules

      Never use wifi for IoT devices. It's too big of a security risk to have devices with a binary blob that are not updated, can connect to web services autonomously/directly, and can offer an attractive stepping stone to your laptop/etc.

      All those IoT hacks you keep reading about? Wifi devices..

      posted in General Discussion
      alowhum
      alowhum
    • RE: be aware of previous used arduino as serial gateway

      This is exactly why the Candle Manager always flashes the MySensors clear sketch before flashing the actual code.

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @badmannen said in Mozilla Webthings MySensors add-on / adapter:

      @alowhum did it your way and it works like a charm. 🤘👍🏻

      I'm not sure what you're talking about?

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Interesting. I'll see if there's an 'official' way to implement battery level.

      // Asked a question on how to implement it.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      A bit of a side-note, but I've created a theme (the very first one!). It also adds thermostat setpoint buttons.

      0_1574289908600_square-theme.png

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Everything nRF52840

      @NeverDie Thanks for the summary 🙂

      Andreas Spiess also never takes things like privacy, and to a lesser degree security, into consideration when he talks about things. For that reason I boycott anything that uses IoT and Wifi in the same sentence.

      posted in Hardware
      alowhum
      alowhum
    • RE: Voco - Voice control for your MySensors network

      According to that link you already solved it, and it was caused by the external access option. Nice work.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Launch a function instead of control a relay, is it possible ?

      Sounds possible. Just try it, and enjoy learning.

      posted in Development
      alowhum
      alowhum
    • RE: Voco - Voice control for your MySensors network

      This add-on has also been updated, and now uses the latest version of Snips again.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      @rmalbers Thanks for suggesting the idea.

      @rmalbers said in Mozilla Webthings MySensors add-on / adapter:

      In other news, it looks like they added metric to the gateway with the new release last night and all my temp readings reverted to 'Cent', the new default, until I switched it off 'metric', scared me for a second!

      Yeah I have to figure out how the add-on can get this value from the gateway instead.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Dynamic change of variable name

      Not to my knowledge.

      Generally you'd create a function that takes an input value, and change that?

      posted in Troubleshooting
      alowhum
      alowhum
    • RE: Interesting new low power display available

      Sounds and looks good. I hope they make an I2C version. Imagine its library being drop-in compatible with the existing OLED displays. That would be something.

      Hmm, this doesn't look good:

      The display is 'write only' which means that it only needs 3 pins to send data. The downside of a write-only display isthat the entire memory must be buffered by the microcontroller driver.

      If you have one of the older 96x96 pixel versions, then 96x96 bits = 1,152 bytes. On an Arduino Uno/Leonardo that'shalf the RAM available and so it might not be possible to run this display with other RAM-heavy libraries like SDinterfacing.

      posted in Hardware
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      It has been accepted.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensor Things - show up 'as active' when they are unplugged

      I've submitted a new version of the add-on that supports this.

      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: Mozilla Webthings MySensors add-on / adapter

      Version 1.0.0 has been submitted to Mozilla.

      • Support for time-outs. After a user-defined period of not receiving any sign of life (data/heartbeat), a node will be set to disconnected.
      • Support for the new WebThings thermostat capability.
      posted in Mozilla WebThings Gateway
      alowhum
      alowhum
    • RE: MySensors gateway and network reliability

      @mfalkvidd said in MySensors gateway and network reliability:

      @alowhum MySensors resets the watchdog every time loop() is exited, so there is no need to call wdt_reset() unless you do something that takes a long time. If you do stuff that takes a long time you should call wait() instead, so messages can be processed.

      Very interesting! If I don't call wait() manually, when does the library process messages? Also at the end of the loop?

      Maybe the mysensors code should enable watchdog by default?

      Sounds good to me! What is the code/memory overhead of doing this?

      If the wdt_reset function is already being called in every loop, doesn't that imply that Arduino also already loads the entire watchdog code? Otherwise, wouldn't that cause a "function not found" error?

      posted in Troubleshooting
      alowhum
      alowhum