• Storing variables

     asch updated 5 years, 6 months ago 2 Members · 2 Posts
  • chiz

    Member
    May 22, 2019 at 8:40 pm

    Is there a way to store dynamically updated variables after a reset / power off.

    I utilise MQTT and would like to be able to update things via MQTT like server, password as well as other parameters, without having to update the program.

    I have considered utilising the USB port but wasn’t sure which library to use to do it.

  • asch

    Member
    May 27, 2019 at 10:14 am

    When you plug the USB from a PC then you can connect to it using a serial terminal. (Minicom for example in the Linux world but there are plenty alternatives in all OSes.) Your program has to initialize and read the serial interface which is connected to through the USB-serial to the PC.

    Arduino IDE also has a simple serial console that can also be used. There are plenty Arduino examples for this. So you don’t even need Minicom or any similar.

    When the serial client is connected to the Controllino then it triggers a reboot (similarly as on Arduino – see documentation there if you are interested in the details) which first starts the bootloader but after its timout your program is restarted and you can communicate to it through the serial connection. All settings of the serial connection must be the same on both sides. (Baud rate, stopbit and parity.)

    When you have serial connection from PC then you can define any protocol you like. For manual update of password a simple line based communication can be enough.

    When the password is inside the program that can be saved into the EEprom part of the chip. This library can be used: https://www.arduino.cc/en/Reference/EEPROM

    Other methods for serial connection:

    * Serial connection can also be simply automated from scripts using the socat program. Example that connects serial to stdin/stdout: socat /dev/ttyACM0,b9600,raw,echo=0,crnl –

    * It is possible to connect from program directly from languages where there is a proper serial library (C, Java, etc). If Data Ready is correctly programmed before connect it is also possible to connect without triggering a restart. Because reset is triggered by an edge on the DTR line which is a control line of serial connection but it is possible to prevent from changing. I have done it once in the past with Arduino but I don’t remember the details exactly.

Viewing 1 - 2 of 2 replies

Log in to reply.

Original Post
0 of 0 posts June 2018
Now