custom circuit board for i2c soil moisture questions

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

custom circuit board for i2c soil moisture questions

#1 Post by bobbybeans » 25 Jun 2017, 00:29

So I started making a custom circuit for the i2c soil moisture sensor. It will be essientailly a daughter board where you plug everything else into it. It will contain an esp12, 6x headers that I will be able to connect jtag cables to that will connect to the 6 individual i2c soil moisture sensors, 2 relays to activate pumps (might extend this to 4) a DHT22 header, and a pin for a servo connection. I have a few questions as I no professional in PCB/circuit design

Researching it
the pins are as follows on this i2c soil moisture
pin 1 - MISO
pin 2 - VCC
pin 3 - SCK / SCL – I2C clock
pin 4 - MOSI / SDA – I2C data
pin 5 - RESET
pin 6 - GND


1) does the / in SCK / SCL mean i can use sck OR scl? and if i use that do i have to use those in pairs? like SCK and MOSI or SCL and SDA? (i wouldnt be able to use SCK / SDA for example?
2) i read the default address is 0x20, i found on one other post someone using 4, how to i change the default address? and whats the max addresses esp will support?
3)From what I found you need to add pull up resistors to the SCK/SCL and MOSI/SDA and MISO. Is this true? if so what value? i have found some forums that say 1k is fine, others 4.7k and another that was using 10k, i was going to do middle of the road and us 4.7k
4) If i need to add resistors does each individual header need its only resistor? what I mean by this is I can't just use 1 - 1k resistor (or w/e the correct value) to all 6? I guess that would be in parralel? yes? OR do I need to have each sensor have its own pull up resistors on each SCL/SDA/MISO as the signals might get messed up by cross talk or something like that?
5) also where do i hook up reset... i have generally looked over the github and can't find where i would hook it up to the esp. Would this just be pulled low by a certain pin if I wanted to reset the device? - again would this need a pull up resistor and would i attach it to a standard ESP12 pin to issue a reset ( i will probably run out of pins at this point)


Sorry for all the questions. I will post the circuit once I have it laid out so everyone can use it

EDIT: may have found my answer sort of for 1 https://www.letscontrolit.com/forum/vie ... 148#p17148 This was really into what relation to what pins to use. can someone clarify ty

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: custom circuit board for i2c soil moisture questions

#2 Post by Shardan » 25 Jun 2017, 11:41

bobbybeans wrote: 25 Jun 2017, 00:29
the pins are as follows on this i2c soil moisture
pin 1 - MISO
pin 2 - VCC
pin 3 - SCK / SCL – I2C clock
pin 4 - MOSI / SDA – I2C data
pin 5 - RESET
pin 6 - GND

1) does the / in SCK / SCL mean i can use sck OR scl? and if i use that do i have to use those in pairs? like SCK and MOSI or SCL and SDA? (i wouldnt be able to use SCK / SDA for example?
As far as i know the chip on the sensor is programmed over a SPI port. Due to that the connector contains two ports in one:
MISO,MOSI,SCK - SPI port for flashing the chip on the sensor.
SCL,SDA - I²C-Port for daily use.

So just don't worry about the additional pins, just use SCL,SDA,VCC and GND, that's all.
2) i read the default address is 0x20, i found on one other post someone using 4, how to i change the default address? and whats the max addresses esp will support?
I don't know the sensor. Do you have a link to the page? Maybe i can find something.
3)From what I found you need to add pull up resistors to the SCK/SCL and MOSI/SDA and MISO. Is this true? if so what value? i have found some forums that say 1k is fine, others 4.7k and another that was using 10k, i was going to do middle of the road and us 4.7k
Well, this is a bit difficult to explain.
The original purpose I²C was developed for is connecting chips inside a device, a TV-set or a DVD-Player for example.
This says: Short connections. For that 10KOhm resistors will do.

The longer the connection gets the more the influence of the cable (technically: the impedance) on the data transfer grows.
This can be compensated by lowering the resistor's value.

1 KOhm is the lowest value the I²C chips can handle.
This limits the length of I²C cabling to a very few meters.

In your case you will need some cable so you may try 4,7KOhm or 2,2KOhm.

Another point that lowers possible cable length: The number of connected devices.
The more devices you put on the line, the lower the cable lenght!

A workaround for cabling length limits:
Some modern devices (HDMI for example) use I²C on cabling up to 10..15 meters.
But they do not connect directly, they use a "Line Driver" chip. Usually these are level shifters too, driving the line with 5V instead of 3,3V.
One example is the PCA9507 Chip : http://www.nxp.com/docs/en/data-sheet/PCA9507.pdf
A more helpfull description besides the datasheep: https://www.eeweb.com/company-blog/nxp/ ... us-buffers

Anyways give it a try just with low resistors, it might work well.
Use a high quality cable, a CAT5 or CAT6 network cable for example.
4) If i need to add resistors does each individual header need its only resistor? what I mean by this is I can't just use 1 - 1k resistor (or w/e the correct value) to all 6? I guess that would be in parralel? yes? OR do I need to have each sensor have its own pull up resistors on each SCL/SDA/MISO as the signals might get messed up by cross talk or something like that?
Just one pair of resistors. You may put it on one (!) sensor or on the board.
Technically it might be possible to use more then one pair of resistors. Remember they are used in parallel then and the lowest allowed resistance is 1KOhm.
So you may use one pair of 1KOHM or two pairs of 2,2KOHM or four pairs of 4,7KOhm... and so on.
5) also where do i hook up reset... i have generally looked over the github and can't find where i would hook it up to the esp. Would this just be pulled low by a certain pin if I wanted to reset the device? - again would this need a pull up resistor and would i attach it to a standard ESP12 pin to issue a reset ( i will probably run out of pins at this point)
Just leave it untouched.


Hope that helps
Just a hint: Before designing a PCB test it on a breadboard, preferably with the sensor cable length you want to use.
Thats no warranty for a working PCB but it increases chances ;)


Regards
Shardan
Regards
Shardan

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: custom circuit board for i2c soil moisture questions

#3 Post by bobbybeans » 25 Jun 2017, 12:59

Thanks for all the wonderful info. i will only worry about SDA/SCL then

I don't know the sensor. Do you have a link to the page? Maybe i can find something.
duh, i should have included that. thats my fault. here it is https://www.tindie.com/products/miceuz/ ... re-sensor/
on the explanation pages it says the default address is 0x20 and somebody in this forum created a plugin for this soil moisture sensor. What I am just confused about is how would i change the listening address on those devices? do I reporgram them to listen on the different addresses. I had a look at the plugin and it allows you to enter the address. Its plugin P047_i2c-soil-moisture-sensor


Well, this is a bit difficult to explain.
The original purpose I²C was developed for is connecting chips inside a device, a TV-set or a DVD-Player for example.
This says: Short connections. For that 10KOhm resistors will do.

The longer the connection gets the more the influence of the cable (technically: the impedance) on the data transfer grows.
This can be compensated by lowering the resistor's value.

1 KOhm is the lowest value the I²C chips can handle.
This limits the length of I²C cabling to a very few meters.

In your case you will need some cable so you may try 4,7KOhm or 2,2KOhm.

Another point that lowers possible cable length: The number of connected devices.
The more devices you put on the line, the lower the cable lenght!

A workaround for cabling length limits:
Some modern devices (HDMI for example) use I²C on cabling up to 10..15 meters.
But they do not connect directly, they use a "Line Driver" chip. Usually these are level shifters too, driving the line with 5V instead of 3,3V.
One example is the PCA9507 Chip : http://www.nxp.com/docs/en/data-sheet/PCA9507.pdf
A more helpfull description besides the datasheep: https://www.eeweb.com/company-blog/nxp/ ... us-buffers
I wasn't planning on having crazy long cables. I was planning on using these originally https://www.aliexpress.com/item/10pcs-F ... 04136.html
but now that i only need to use 4 pins instead of what i thought 6 pins i will probably end up buy a 4 pin jtag.

Hope that helps
Just a hint: Before designing a PCB test it on a breadboard, preferably with the sensor cable length you want to use.
Thats no warranty for a working PCB but it increases chances ;)
haha indeed i was going to lay it out. just have to wait for parts to come in :)

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: custom circuit board for i2c soil moisture questions

#4 Post by Shardan » 25 Jun 2017, 16:03

Hello again,

there is no word about adress setting in the description and i don't see any possibility to set it via hardware.
There is one point in the description thats interesting:
Do not hotplug the sensor into the active I2C bus - address change command has no protection and this might result in a random number set as an address of the sensor. Use I2C scan sketch to find out the address if the sensor stops responding with proper values.
Seems the processor seeks for the I²C address automatically?

Just being curious: Do you use a software do layout the PCB?
I'm using Kicad atm.

Regards
Shardan
Regards
Shardan

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: custom circuit board for i2c soil moisture questions

#5 Post by krikk » 25 Jun 2017, 16:44

the sensor you have can change its address via software, this is supported by the espeasy plugin i wrote (only in latest 2.x builds)...

i have 5 of this sensors running on my balcony to monitor my plant pots... and one lession i have learned is, that i should have used twisted pair cables, i used simple RJ-12 cables (like this one) and i am nearly at the limit of the i2c bus...

a have kind of a star topology the center is this bus board: https://www.aliexpress.com/item/RJ45-8P ... 0.0.qLvPLy from there i have 2x 3m cable + 3x5m cable and it works with 1k resistors, higher resistors do not work anymore, so use better cables than me :) ...another lesson learned is that you should only apply a thin epoxy coating otherwise sensivity is lower... :)

bobbybeans
Normal user
Posts: 119
Joined: 26 Feb 2017, 17:30

Re: custom circuit board for i2c soil moisture questions

#6 Post by bobbybeans » 25 Jun 2017, 20:08

krikk wrote: 25 Jun 2017, 16:44 the sensor you have can change its address via software, this is supported by the espeasy plugin i wrote (only in latest 2.x builds)...
oh nice! didn't know this. I was actually just looking through all the documentation and found this https://github.com/Miceuz/i2c-moisture- ... /README.md you can change the address if you load an arduino up with the code all the way at the bottom. will be trying to load that again with the test builds of the 2.+
i have 5 of this sensors running on my balcony to monitor my plant pots... and one lession i have learned is, that i should have used twisted pair cables, i used simple RJ-12 cables (like this one) and i am nearly at the limit of the i2c bus...
ahh didn't think about the twisted pair, might have to rethink my jtag arragement (luckily haven't ordered them yet). However I will be monitoring basil, mint and other herbs indoors so the cable legnth doesnt need to be long. 30 cm maybe
a have kind of a star topology the center is this bus board: https://www.aliexpress.com/item/RJ45-8P ... 0.0.qLvPLy from there i have 2x 3m cable + 3x5m cable and it works with 1k resistors, higher resistors do not work anymore, so use better cables than me :) ...another lesson learned is that you should only apply a thin epoxy coating otherwise sensivity is lower... :)
by the descriptions it looks like it already has a thin coat of epoxy, what I was going to do is put a thin layer over only the top half where the circuit is and leave the bottom as it, with its shiny coat. then take a ballon and cover the top of the circuits, cover the entrance of the ballon in silicon grease to stop water ingress. the suggestion of the ballon was actually on the creators website. take one of those long thin ones used to do ballon animals

krikk
Normal user
Posts: 118
Joined: 28 Feb 2017, 07:57
Location: Austria
Contact:

Re: custom circuit board for i2c soil moisture questions

#7 Post by krikk » 25 Jun 2017, 21:36

for 30 cm cable lenght you can use any cable... :)

for indoor use your "coating" should be enough, but for outdoor use epoxy resin is a really good choice, had no problem and the sensors are out now for about 1 year

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests