Hardware
This post summarises 2 sessions. We added a pull-up Resistor between the Raspberry and the probes counter reset line to remove uncertain behaviour in case the raspberry is booting up or is unconnected. You can get rid of the uncertain behaviour by just resetting the MCP and the counters but practices helps remembering :).
Further we found out, that the windprobe we ordered sends a pulse every 1/2 turn and not as anticipated once per turn. This we will need to keep in mind for the counting and to make sure our filter is not cutting off the maximum windspeed we were aiming for.
Brice introduced us to the basics of a bus. These limitations have to be kept in mind because there is signal bouncing happening in the bus. (Think of it kind of like water ripples if you build a physical water channel model of the bus and produce ripples on one end. The ripples bounce of the ends and bounce back to the producer, creating noise.)
- The bus needs pull-up Resistors at the end of the line.
- A bus can never be a star configuration (https://en.wikipedia.org/wiki/Star_network)
- All devices on the bus have to physically come one after another on the bus.
- The connection between the device and the bus should be as short as possible.
Software
Our setup now is a wifi router connected to the internet, the raspberry connected via lan to the router and a laptop connected to the router aswell. We found the IP address of the raspberry on the router and connected to the raspberry via ssh (we use putty to connect (192.168.1.159:22 for us)).
To configure the raspberry to work via ssh check this raspberry manual page: https://www.raspberrypi.org/documentation/remote-access/ssh/ (Enable SSH on a headless Raspberry Pi (add file to SD card on another machine)). Once we logged in on the raspberry we run 2 commands.
- sudo apt update
- sudo apt install i2c-tools
After that we have to enable i2cdetect to finally be able to read from our bus. To configure we write “raspi-config” navigate to 5 (Interface) and then I2C enable.
Now everything is set to check our bus. As you can see we have our device (here as 20) on the bus address 0x20 (column 0, row 20). The device is 20 because we configured the hardware pins to be 000 by grounding all 3 of them. The 4 predefined Bits are 0100. This means our Device is Binary 0b01000000 which in Hex is 0x20.
After a light reading in the manual we found how to read the bits. To program the MCP we will have to do a deep dive into the MCP datasheet ( http://ww1.microchip.com/downloads/en/devicedoc/20001952c.pdf) to check if everything works we just use the raspberry with the command “i2cget -y 1 0x20 0x12” and “i2cget -y 1 0x20 0x13“. See the i2c manual here ( https://www.waveshare.com/wiki/Raspberry_Pi_Tutorial_Series:_I2C and here https://linux.die.net/man/8/i2cget)
- i2cget: read bytes
- -y: Disable interactive mode
- 1: Indicates the number or name of the I2C bus to be scanned.
- 0x20: Address of the MCP I/O extension
- 0x12: Addres in the MCP to read the first 8 bits, see next screenshot
- 0x13: Addres in the MCP to read second 8 bits, see next screenshot
As you can see by turning the probe and reading the registers the number is increasing. Once we pass 0xFF it is reset to 0 and we can read on the second Bit bank.
Github Link: https://github.com/TheCell/Weatherstation
Archives
- November 2023
- December 2022
- November 2022
- February 2022
- November 2021
- October 2021
- September 2021
- July 2021
- April 2021
- March 2021
- February 2021
- January 2021
- September 2020
- July 2020
- April 2020
- March 2020
- February 2020
- December 2019
- November 2019
- October 2019
- August 2019
- June 2019
- February 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- May 2018
- March 2018
- February 2018
- December 2017
- November 2017
- September 2017
- July 2017
- June 2017
- April 2017
- February 2017
- January 2017
- October 2016
- September 2016
- July 2016
- May 2016
- April 2016
- March 2016
- August 2015
- July 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- October 2014
- April 2014
- March 2014
- February 2014