Hackers needed: help run 2.0 software on 1.0 HW


#45

Hi @gordonb.
I have done the rest of the sensors. And tested them on Raspberry Pi 3, with Arduino Mega of course.
It is not stable yet sometimes it shows this error “Lost sync with device, restarting…” and I think that is because I am pushing too many data at the same time. I am still working on it.
I was able to do the TSL2561, DFR0161, and DFR0300. Also, I modified the code for DS18B20 and changed the variable from “_temperature” to “_water_termperature”. Because I was getting an error that “temperature is non-exciting variable”.
Due to the reason that electric conductivity sensor requires the temperature of the water. I will try and put both sensors in the same code. For now, I replaced the water temperature with the value 25 C. Hopefully, I will work on it on the weekend.
Feel very to copy the code and modify it if you feel it is necessary.


Cheers.


#46

@Khallad this is amazing!

It is not stable yet sometimes it shows this error “Lost sync with device, restarting…” and I think that is because I am pushing too many data at the same time.

That is probably caused by sensor misconfiguration, or perhaps a missing sensor. See this bug: https://github.com/OpenAgInitiative/openag_brain/issues/76. I’m working on a fix that will replace error messages in firmware with error codes to prevent buffer overflow.

I’ll take a look at the rest asap. Thanks!


#47

Hi Khallad, I’ve also been working on the TSL2561 sensor, https://github.com/MisterBurnley, and have the same error when running the code with the brain. It works fine when tested outside the system using, openag firmware run_module -p csv -t upload, and gives output using , platformio serialports monitor.

If it’s OK with you I’ll try out your code for the TSL2561 and feed back how it goes.

Have you tried using the docker image ?

John.


#48

What do you mean by missing sensor? I mean I am getting data on the UI for each sensor. Sometimes they are delays. But I read on another thread that it is a bug.
Sensor misconfiguration has crossed my mind. I need to look into it more.
Update me if you tried the codes.


#49

Hi,
I only tried it with the brain and not the docker image. I actually haven’t thought of using the docker image.
Feel free to clone it to your repository and if you think any modifications is needed do it yourself. Just update me. So, we can be on the same page.


#50

@Khallad

What do you mean by missing sensor?

I mean that this error is caused by one or more sensor firmware sending back an error (whatever the reason is). The original software architecture has the sensor firmware send back an error message, but if the message is too long, or too many messages, the message buffer will overflow. The bug I linked to goes into detail. I’m working on a fix that replaces messages with 8-bit error codes to avoid the problem.


#51

Hi Khallad, just tried this on your code,

pi@raspberrypi:~ cd openag_tsl2561 pi@raspberrypi:~/openag_tsl2561 openag firmware run_module -p csv -t upload

and got the following errors ,
/home/pi/openag_tsl2561/_build/src/src.ino:13:9: error: no matching function for call to ‘Tsl2561::Tsl2561()’
std_msgs::Float32 module_light_illuminance_msg;
^
/home/pi/openag_tsl2561/_build/src/src.ino:13:9: note: candidates are:
In file included from /home/pi/openag_tsl2561/_build/src/src.ino:1:0:
.pioenvs/megaatmega2560/module/openag_tsl2561.h:90:3: note: Tsl2561::Tsl2561(int)
Tsl2561(int _TSL2561_Address);
^
.pioenvs/megaatmega2560/module/openag_tsl2561.h:90:3: note: candidate expects 1 argument, 0 provided
.pioenvs/megaatmega2560/module/openag_tsl2561.h:81:7: note: Tsl2561::Tsl2561(const Tsl2561&)
class Tsl2561: public Module {
^
.pioenvs/megaatmega2560/module/openag_tsl2561.h:81:7: note: candidate expects 1 argument, 0 provided
.pioenvs/megaatmega2560/module/openag_tsl2561.h:81:7: note: Tsl2561::Tsl2561(Tsl2561&&)
.pioenvs/megaatmega2560/module/openag_tsl2561.h:81:7: note: candidate expects 1 argument, 0 provided

Funny thing is that even though the compilation failed, when I ran, platformio serialports monitor, it gave me a readout from the sensor. I thought that if the code didn’t compile then it shouldn’t work !!! Have a meeting tonight, busy tomorrow am, will give it another look tomorrow afternoon.

john


#52

Hi @JohnB

Can you try and run it using the brain then write this command on another session rostopic echo /environment_1/measured/light_illuminance. Do you see any values??


#53

Hi, I am using the latest openag_docker_brain_rpi code and will have to create new default and sensor box fixtures to incorporate your code for the tsl2561 into my database before I can test it further.
I have a dht22 and a TSL2561 connected to my arduino and have tried using my code for the TSL2561.
When I shell into the running docker brain and use rostopic echo then there are values output from both sensors.
Could you try my code on your set up while I create a fixture for your tsl2561 sensor code and try it, now that I know how to use the Docker_brain and get some output.
Don’t know if Gordon has had the, https://github.com/OpenAgInitiative/openag_brain/issues/762, inserted into the openag_docker_brain_rpi yet or if it is automatically updated when main code base is changed but the copy I used yesterday is now working with my set up and is giving traces on the hosted UI, Yeeeh !!!


#54

Code for you to add to your Firmware module type database,
{
"_id": “tsl2561”,
“repository”: {
“type”: “git”,
“url”: “https://github.com/MisterBurnley/openag_TSL2561Ada.git
},
“header_file”: “openag_lit2561.h”,
“class_name”: “LIT2561”,
“description”: “”,
“arguments”: [
{
“name”: “i2c_address”,
“type”: “int”,
“default”: 29
}
],
“outputs”: {
“light_illuminance”: {
“type”: “std_msgs/Int32”
}
},
“dependencies”: [
{“type”: “git”, “url”: “https://github.com/OpenAgInitiative/openag_firmware_module.git”}
]
}

and this is what I have in the module type database, as I am only using two sensors at the moment
note the underscores aren’t being displayed in the id line of the, firmware module code, when the edit is posted to the forum ???

{
“firmware_module”: [
{
"_id": “tsl2561_1”,
“type”: “tsl2561”,
“environment”: “environment_1”,
“arguments”: [29],
“output”: {
“light_illuminance”: {“variable”: “light_illuminance”}
}
},
{
"_id": “dht22_1”,
“type”: “dht22”,
“environment”: “environment_1”,
“arguments”: [2],
“outputs”: {
“air_temperature”: {“variable”: “air_temperature”}
},
“air_humidity”: {“variable”: “air_humidity”}
}
],
“software_module”: [
]
}


#55

Hi, just had a closer look at your code and it looks like you have missed out the arguments in the module.json fle. eg,

{
“description”: “Openag modified Adafruit driver for the Grove TSL2561 Digital Light Sensor”,
“class_name”: “LIT2561”,
“header_file”: “openag_lit2561.h”,
“arguments”:[
{
“name”: “i2c_address”,
“type”: “int”,
“default”: 29
}
],
“outputs”: {
“light_illuminance”: {
“type”: “std_msgs/Int32”
}
},
“dependencies”: [
{“type”: “git”, “url”: “http://github.com/OpenAgInitiative/openag_firmware_module.git”}
]
}
They tell the system to use the i2c bus with address 29.
The TSL2561 has three possible addresses, mine is set to 29. it depends who made the board the sensor is mounted on, This is the Adafruit board info, https://learn.adafruit.com/tsl2561/use# there are also links to their software and other related info.


#56

Hi just ran your code with the the arguments added to the module.json file and it compiles and is giving output to platformio serialports monitor. If it works for you then when you update your repo copy i’ll try it on, openag_brain_docker_rpi,
I’ve been trying to re-compile my ROS install but can’t get the dependencies sorted ??? That’s why I started using the Docker image.
Great work getting all the three missing sensors sorted, I’m just pleased I’ve managed to get as far as getting one lot of code working with help from Gordon and Serein.


#57

Hi @JohnB

I did. It didn’t work. Errrrrrrrrrrrrrrrrr!!!

are you sure about the “_id”??
I did it according to this example: https://github.com/OpenAgInitiative/openag_brain/blob/master/doc/fixtures.rst
last brain update I have is I think from two weeks ago. Since it is working for me I am a little bit afraid of updating to the newer version. :sweat_smile:

I modified it. Forgot to add it in module.json. but I did add it to firmware module type!!

The thing is my docker image is very very old last time I used it is maybe a month ago. And I have done some changes to the brain to be able to add recipe and get readings!!!

Can you try and add firmware module for the TSL2561 alone and not both sensors in the same module??
{
"_id": “tsl2561_1”,
“environment”: “environment_1”,
“type”: “tsl2561”,
“outputs”: {
“light_illuminance”: {
“variable”: “light_illuminance”
}
}
}
For frimware module type
{
"_id": “tsl2561”,
“description”: “Digital Light Sensor”,
“repository”: {
“type”: “git”,
“url”: “https://github.com/KhalladB/openag_tsl2561.git
},
“class_name”: “Tsl2561”,
“outputs”: {
“light_illuminance”: {
“type”: “std_msgs/Float32”
}
},
“header_file”: “openag_tsl2561.h”,
“arguments”: [
{
“default”: 29,
“type”: “int”,
“name”: “TSL2561_Address”
}
],
“dependencies”: [
{
“url”: “https://github.com/OpenAgInitiative/openag_firmware_module.git”,
“type”: “git”
}
]
}

By the way, this sensor is the sensor that causing is this problem. [quote=“Khallad, post:45, topic:694”]
It is not stable yet sometimes it shows this error “Lost sync with device, restarting…”
[/quote]
And I will look into most probably tomorrow.

Cheers


#58

Hi Khallad, Haven’t tried using your code yet as I thought I’d start my docker image again and check that it still worked first.
You guessed, it didn’t, no data from the sensors when I tried, rostopic echo, but they were all there when I used, rostopic list. ???
How come it worked last night ???
I went through all the commands I had issued and found that I had opened a second terminal and issued the, platformio serialports monitor, command to try and see if there was any data on the serial port. I tried it again and it just gave a series of errors about the serial port. I then tried the rostopic echo command and it started printing data to the terminal screen. Both the dht22 and the TSL2561 were issuing data. When I started the UI the data was traced to the screen and has been stable for over an hour.
Don’t know why, so I’m going to raise the issue on github openag_brain #80.The errors I’ve posted are about sync problems. Once I’ve done that I’ll swap my database, firmware_module_type, code to point to your TSL2561 code repo and see if that works.


#59

Sorry I’ve moved the note about the underscores to just above the ‘firmware_module’ code to which it refers.


#60

Hi Khallad, just finished trying your code for the TSL2561 in my setup eg, using the openag_docker image.
So long as I interrupt the running system by running, platformio serialports monitor, from a second terminal, the serial error is reset and the sensors keep sending data without stopping
You can check out the errors as I’ve posted them on openag_brain issue #80.
I haven’t run the TSL2561 on it’s own as it works OK with the dht22 connected. That’s not to say that more sensors will work and I haven’t got any binary, pwm or software actuators initialised yet.

Great work, there are now two working software drivers for the TSL2561 sensor.

NB the openag_brain_docker_rpi code has been updated ( tonight, local time ). Here is a screenshot of output to the UI using your code for the TSL2561 and the updated docker code.


#61

Hi @JohnB,

Congrats!!!

I tried rostopic echo for the TSL2561 (My code). I kept getting data so fast. I have removed it from the firmware_module for now until I see where the problem is. The other sensors are currently installed and I am not getting “Lost sync with device, restarting…”. So, I figured TSL2561 is what causing the problem. And until now I don’t know why!
Today, I will start writing a code to put both ds18b20 and dfr0300 together.

I am currently trying to add the actuators. But finding difficulties because I couldn’t find any guidance on how to add them. I have only managed to control a binary actuator manually using rostopic. If you have any information that might help please share them.

Cheers


#62

Dear all, a few days ago, I installed open_brain_docker_rpi in a new SD card, inserted it in the RPI of my PFC 1.0 and I was able to start the 2 docker container, and log through http://openaginitiative.github.io/openag_ui/.

I saw the new interface, but nothing happened … It did seem that the Arduino was not working.

Anyone who has make work a PFC 1.0 with 2.0 software, could you please provide some light about the software installation?

Thank you in advance


#64

I have the same question.I saw the new interface of UI but no data inside. Also the arduino didn’t work. I open http://:5984/_utils/ and didn’t see much DB data inside.


How to set up and test a fixture?
#65

Hi @gordonb,

Is there a way that I can get the data from ds18b20 and use in the dfr0600 code?? I am trying to put both sensors in one code. But I am getting a lot of errors.

Thank You


How to set up and test a fixture?
Is PFc v1 still viable?