I²C communication

Hello everyone,

As part of my bachelor thesis, I would like to expand the I²C communication in the firmware. The commands F51 and F52 are already reserved for this purpose. In order to have a more precise idea of how these two F-code commands should work, I would appreciate a more detailed description.

Should all sensors that communicate via I²C be able to be picked up as a tool (like the soil sensor) and then controlled using the commands? Or is the communication not necessarily about sensors?

Many thanks in advance.

Best,
Finn

1 Like

Hi @Finn

That’s up to you. The UTM cable has two wires for I²C communication on 1 bus. They terminate in the UTM on pins I and J so you don’t have to use a detachable tool.

Bear in mind that the UTM Jumpers on the Farmduino for I²C signals may need installing.

The FarmBot Soil Moisture Sensor has I²C for Temperature but I’d be surprised if any users have that working.

Where did you read this ?

Edit: Ok, I found it in the README.md … the Response codes are missing.
Edit: Likely you’ll need additional Parameters and Values in the Write (set) F51 command (?)
Edit: Is I²C across 4.1 metres of wire (XL) usable ?

1 Like

Hi @jsimmonds,

thank you very much for your quick reply. Originally I wanted to write a code to read I²C sensors in general, but I think this is difficult to realize as each sensor has specific register addresses. Maybe I’ll try to write a program for the temperature sensor, since every FarmBot user already has it but can’t access it. Or did you have another idea for the F52 command?

I think if I keep the baud rate low enough, it should work with the 4.1 meter cable.

Do you have a detailed description of the Soil sensor (or the temperature sensor on it)?

Best regards,

Finn

Hi @Finn no but I went looking on FarmBot’s sites and found photos but no schematic.
You could enquire mailto:contact@farm.bot for the parts details I suppose.

Nope.

I believe that the Soil Sensor PCB is only applicable to Genesis and Genesis XL device UTMs.

That’s the temperature sensor on the RHS leg of the Sensor :slight_smile:

See also

Hi @jsimmonds,

thanks! I’ve texted contact@farm.bot and I’m waiting for a reply now. I saw you already discussed this topic in September last year (What sensors are there on the FarmBot?). I would like the I²C temperature sensor to work. I was wondering if FarmBot developed the sensor themselves or bought it from a company so I can get the informations there. I took a picture of the sensor to get more information, but it did not help much. I’m sending you the picture anyway, in case you or someone else knows where it came from.

1 Like

Hi @Finn

No idea, after an hour of web searching and Google Lens-ing :slight_smile:
I believe, due to the opening in the metal case, that the chip inside is likely one of many MEMS Barometric Pressure and Temperature sensors (current or obsolete) having serial digital interface(s).

1 Like

Just popping in here after responding to Finn over email to make the spec sheet for the chip available to everyone: Soil Temperature and Pressure Sensor ICP-10111.pdf (895.9 KB)

2 Likes

Thanks @jsimmonds and @roryaronson! I’m working on a software program to read out the temperature now. If I have any questions or successes I will get back to you :wink:

2 Likes

Hello again,

I found the library of the icp10101 sensor on the TDK website and added it to the firmware. With the help of the library I wrote the F52Handler, which accepts the parameter P and outputs either the temperature in Celsius (P = 1) Fahrenheit (P = 2) or the pressure in pascal (P = 3). I made a pull request at github (Add F52Handler by FinnRoters · Pull Request #167 · FarmBot/farmbot-arduino-firmware · GitHub). Reading my sensor with the Arduino Mega 2560 has already worked, but I still have difficulties reading it with the Farmduino, which I will work on in the near future. Please write to me if you have any suggestions for improvement.

1 Like

Hello everyone,

I would like to connect various I²C sensors to the FarmBot to better monitor the conditions for plant growth. I have already connected the icp10101 temperature sensor (integrated in the soil sensor) and the SCD30 sensor, which can measure CO2 and humidity, to the FarmBot. Next I would connect the AS7341 light sensor.

At our university we have also considered sensors that can measure magnesium, phosphorus, calcium or pH in the soil, but these sensors are usually very expensive and often require maintenance. If anyone here has any ideas for I²C sensors that would be suitable for the FarmBot, I would be very happy to hear from you.

Many thanks in advance.

1 Like

Hello, I’m currently having the problem that I can read and print the values from my I²C sensors with a newly created F52 handler in the firmware, but unfortunately I can’t display them on the website. Is there a way to display the values in the WebApp without changing the operating system, which is very confusing for me, or the web source code? One of my thoughts was to manipulate the F42 handler, which can read out a pin P digitally or analog, so that if, for example, pin 0 is to be read out analog, it simply gets back the I²C value read out and I can see it in the sensor area on the website.
grafik

This is not a clean variant, but I think it should work. Let me know if you know a better way, maybe with Lua or something.

Lua gcode() gives you raw firmware access so you could use F52 directly and not bother with Named-Pins ( aka Sensors ) at this stage ?

1 Like

Perfect, seems like I missed that. Thank you a lot @jsimmonds!

@Finn don’t get too excited :neutral_face:

Until just now, I never used that function and the documentation did not mention any function return value (!) … seems it is a ‘fire and forget’ request; i.e. it sends the command to firmware but does not wait for or return the firmware response to Lua, so not what you want :face_with_diagonal_mouth:

I’ll give this some more thought.

Edit: Just tested “G00” and Lua code did block until the movement completed but return was still null (nil)
We just need to get that Rnn firmware response sent to our Lua process !

Edit: Hi @roryaronson does this behaviour of gcode() look like a bug in FBOS ?

Seems like you’re right :frowning:

I tried to run F42 (Read a value from an arduino pin P in mode M (digital=0/analog=1)) and display the value, but it responded with nil:

Yup, but your code specifies a V parameter, and M is missing :confused:

I’m going bug-hunting to see whether we can make this function work. Would be nice to get a fix into the soon-to-be-released FBOS version 15.4.11

Edit: The correct raw firmware response is coming back to FBOS, just not being returned to Lua.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.