Navigation

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

    OldSurferDude

    @OldSurferDude

    37
    Reputation
    112
    Posts
    115
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    OldSurferDude Follow

    Best posts made by OldSurferDude

    • RE: What's a good power bank for use with IoT?

      @NeverDie I am happy to report that my batteries arrived yesterday!

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: What's a good power bank for use with IoT?

      @NeverDie
      I'm going to dissipate the energy through a 25 ohm resistor. It will take about 24 hours to perform one capacity test. Often times I read that the full capacity won't be available until after a few charge-discharge cycles. 2 resistors, 4 batteries, 3 tests each. Assuming that I stay on top of it, it will take at least a week of testing which won't start until I get my 25 ohm resistors. I'll post a link to my full write up.

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: What's a good power bank for use with IoT?

      OK, I did my battery test. @NeverDie @Nca78 @mfalkvidd
      You can find it here

      The batteries from Newegg and Fullbattery are good ones.

      If you going to buy a large quantity and looking for a low price, then you should buy 1 or two and test them as I have done here. You might have to "kiss a lot of toads" before you find a good vendor, though.

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: Beginner concept question for serial communication

      @hubertus I'm not getting the description of you setup. Perhaps a sketch would be good?

      Wen I need serial communication, with the Arduino, I use SoftwareSerial on two other I/O lines. That way I can debug real time, SoftwareSerial is slower but you're only doing temperature so 9600BAUD would be fin

      Also, don't try to do too much at once. Break the task down into small, manageable sections. You have a lot of different things going on, get one thing going at a time.

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: What's a good power bank for use with IoT?

      @NeverDie I like your suggestion for solar panels, though my application only requires 1x 5W panel. And I like the idea of dismantling the power packs.

      I think we differ in our approaches, though. I seem to enjoy living on the "bleeding edge", that is, I'm more of a risk taker. My first house solar system, 2.8kW, was installed in 2004. When I upgraded to 4.2kW, I took the 14 panels and installed them on my hillside, so now I'm a net energy exporter. The 2.8kW portion is still producing at 85% of nameplate, shows little environmental degradation (sealant, too), and has paid for itself. The reward outweighed the risk.

      In taking risks, I learn much. Yes, I have a quite a few scars, actually and metaphorically. I have discovered a philosophy: Everything is an experiment. The point of an experiment is to learn something. So every experiment is a successful, just that sometimes the desired results are not realized. Eg. leaving an Arduino outdoors results in a short useful life. Spraying on a sealant extends the outdoor life.

      Good discussion. Thanks for the ideas

      OSD

      posted in General Discussion
      OldSurferDude
      OldSurferDude
    • RE: What did you build today (Pictures) ?

      @NeverDie It is my understanding, though I can't wrap my head around it, that it is the length of the conductor that makes the antenna tuned to a certain frequency. If this is the case, you could run your antenna around the edge of your circular pcb which would make the effective radius only slightly bigger.

      posted in General Discussion
      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: How to optimise a code (95% memory used)

      I found that timelib.h uses a tremendous amount of memory. You avoid using it by getting time string from the controller.

      I have also found that when you're using that amount of memory that bad things happen, as you noted. I use global variables to avoid the transient nature of function variables.

      I'll be looking forward to other comments as, I, too, do not know all the tricks;)

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude
    • RE: What I must buy in order to measure mAh please

      @DenisJ Are you measuring a USB device? Look at something like this https://www.aliexpress.com/item/33019457512.html?gps-id=pcDetail404&scm=1007.16891.96945.0&scm_id=1007.16891.96945.0&scm-url=1007.16891.96945.0&pvid=824c24fa-034b-4801-b51d-50b2ad877945&_t=gps-id:pcDetail404,scm-url:1007.16891.96945.0,pvid:824c24fa-034b-4801-b51d-50b2ad877945,tpp_buckets:668%230%23131923%2330_668%230%23131923%2330_668%23888%233325%239_668%23888%233325%239_668%232846%238110%231995_668%232717%237561%23332__668%233374%2315176%2335_668%232846%238110%231995_668%232717%237561%23332_668%233164%239976%23761_668%233374%2315176%2335

      (AliExpress: Cheap prices and one could question the quality, but for the most part they work. Shipping takes about a month. rarely faster)

      posted in Hardware
      OldSurferDude
      OldSurferDude
    • Send configuration (numbers) from HA to Arduino

      I would like to make changes to my Arduino sensor after it is deployed. I have developed an autocalibration scheme, but it needs its zero point set, which can't be done until it's in its final location. Yes, I suppose I could, with long wires, connect a push button to an input. But that doesn't completely solve the problem because I need to send a number that can be interpreted to be the interval between sending data to HA.

      This is my receive routine:

      //-------------------------------------------------------------------------receive
      void receive(const MyMessage &message)
      {
      	// We only expect one type of message from controller. But we better check anyway.
      	if (message.getType()==V_VAR1) {
          ConfigurationFromMySensors = message.getLong();
      	}
      }
      

      In HA, I would pack the information in a 4 byte integer (long) and unpack it in the loop where I would operate on it as needed.

      But how do I send the 4 byte integer from HA?

      Thanks for your consideration and hopefully, help!

      OSD

      posted in Home Assistant
      OldSurferDude
      OldSurferDude

    Latest posts made by 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
    • completely remove MySensors integration for HA and start over

      I am trying to completely redo the integration. The current integration works, but I am unable to have nodes as part of the gateway. I hoping that starting over from scratch might work. 1st I stop the MySgw. then I delete the integration. This does not delete the persistent data; using Studio Code Server, I delete MySensors data. Next I delete the MySensors topics from the MQTT broker. Finally, I reboot Home Assistant. (In terminal execute reboot) when the reboot is complete, I re-integrate MySensors, ensuring that the version, "in" topics and "out" topics are identical to the MySgw. Then I restart the gateway. The data is getting the MQTT broker, but not to HA. Of course I backed up before doing this and when I do the full restore, all is working as it was before. I expect I should be able to start from scratch. What am I doing wrong?

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: Did HA just give up on MySensors?

      @Dbagioni Interesting. I'm having similar symptoms, but I can still connect new nodes.

      I found that if a node somehow disappears from the Overview, it may still be in the persistent file. In HA, using "Studio Code Server", one will see an entry "mysensors123423e3q132" (or something like that. the first line will be
      "0": {
      and a few lines down a closing
      }
      which is the information for the gateway.
      Look for your node: "node_id": { My experience has been if it is not found, one can add a node with that node_id

      But if you do find it and the node is not one of the devices in under the my sensors integration (Settings→Devices & Services→MySensors/5 devices→SoilMoistSensor node_id), get ready to jump through some hoops.

      Here's what I do. I have an Arduino with a radio already wired. First, I program address 0 of the EEPROM with the errant node_id. See addressUnit.ino below. Then I load the MySensors example SoilMoistSensor onto the Arduino. and run it. At this point, I can see the node in HA under the mysensors integration as SoilMoistSensor node_id. (This node is going to be deleted, but before this is to be done, one must reprogram the Arduino so the it doesn't recreate the node. addressUnit.ino would be a good program to use to over write the SoilMoistSensor program.) Ok, now Click on it. Right below Device info you'll see DELETE in red. Click on that. For me this also removes the code from the persistent file. Then a new device with node_id can be created.

      You can try, but I have not been successful at deleting the code in the persistent file. It seems that there is a persistent, persistent file which repopulates the persistent file.

      addressUnit.ino

      #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();
        }
      }
      

      This is what I posted on HA Discord under "installation"

      HA with MySensors integration (MQTT). I am trying to completely redo the integration. The current integration works, but I am unable to have nodes as part of the gateway. I hoping that starting over from scratch might work. 1st I stop the MySgw. then I delete the integration. This does not delete the persistent data; using Studio Code Server, I delete MySensors data. Next I delete the MySensors topics from the MQTT broker. Finally, I reboot Home Assistant. (In terminal execute reboot) when the reboot is complete, I re-integrate MySensors, ensuring that the version, "in" topics and "out" topics are identical to the MySgw. Then I restart the gateway. The data is getting the MQTT broker, but not to HA. Of course I backed up before doing this and when I do the full restore, all is working as it was before. I expect I should be able to start from scratch. What am I doing wrong?

      When you ask your question, you have to remember that these programs are maintained by volunteers like you and me. The more complicated the change, the longer it will take to have a working change in place.

      If this is problem for you, then you should look at Universal-Devices Polisy. It's a good device and holds a lot of promise and is much better supported.

      For me, I'm holding my breath. Hopefully someone at HA or MySensors knows the trick.

      posted in Home Assistant
      OldSurferDude
      OldSurferDude
    • RE: 💬 Building a Orange Pi Gateway

      I saw this page and thought I give it a go. So I bought two OrangePi Zero 2. There's a lot of potential (WiFi) as a dedicated gateway. Currently the price is about US$20 on AliExpress (caveat emptor) There are a few flavors of Linux for it. I've dabbled with Armbian, Ubuntu and Debian

      Another upside is that it doesn't draw a lot of current ~0.5A, though I haven't been successful in getting the radio to run (the reason for me being here) This is also a downside as I suspect the power supply needs to be very close to 5V. Thinking it was a power hog like the RPi, I used a 5V-3A supply. This supply operates on the principle that the load will pull down the voltage. There are dire warnings on the orangepi page about using cheap SD cards, but failed to mention that power supplies have to be matched, too.

      It has a different CPU than the Orange Pi Zero non-2, the board that is used here.

      Use the serial interface to configure the board. You're going to be doing all your configuration in a terminal, anyway, so you don't need a monitor or a keyboard. https://www.instructables.com/Setup-Orange-Pi-Using-Serial-Port/

      The big downside is that the SPI interface is not supported. My research indicates that in order to get it to work one must jump through some serious hoops and being low on the learning curve, those hoops are probably out of my reach. https://forum.armbian.com/topic/21688-tips-on-configuring-double-spi-through-two-chipselects-on-orange-pi-zero-2/

      The armbian OS has another big downside, WiFi is not supported. Putting a TP-Link nano router configured as a client works, but it's another $30! Why did they even release the OS?

      So! Was anyone successful in getting the Orange Pi Zero 2 configured as a gateway?

      posted in Announcements
      OldSurferDude
      OldSurferDude
    • RE: No LAN connection ESP8266 gateway

      @mfalkvidd @Bramz @electrik

      When I saw 2.6.2 I was thinking the MySensors Library (2.3.2)! It never occurred to me it was the board manager.

      So, yes! it works for me. 🙂

      I just checked to see if Domoticz has an MQTT interface and it appears that it does. @Bramz, look into that. Once you have that, then it may be easy to connect other devices, like Tasmota devices, to Domoticz. MQTT requires an always-on computer connected to your network.

      I have a headless (needs dummy monitor plug or 3x 75Ω resistors to boot), refurbished computer on which I run Linux OS, then both MQTT and Home Assistant running in Virtual Box.

      Thanks everyone!

      OSD

      posted in Troubleshooting
      OldSurferDude
      OldSurferDude