Code Monkey home page Code Monkey logo

stm32f103_ds18b20_modbus's Introduction

STM32f103 ds18b20 ModBus-TCP

Welcome to the stm32f103_ds18b20_modbus project main repository! Data acquisition device for digital thermometers ds18b20 and modbus-tcp server.

WARNING: This project is work in progress! Anything can (and probably will) change! Do not use the code found in this project for any critical system(s). The use of the code and documentation is at your own risk!

In this project he uses a Blue Pill (stm32f103c8t6) and a W5500 ethernet board connected to the SPI1 interface. You can use a 16x2 LCD display, a rotary encoder with switch and a BMP180 barometer. See eschematic.pdf

By default, up to 77 bs18b20 thermometers can be configured, which are read every two seconds. The information of the thermometers is available through the ModBus protocol. The code uses the HAL library and was generated with STM32CubeMX initially.

A configuration interface is implemented by telnet to port 500.

You can choose to enable or disable the following features or modules selecting it in Inc/my_config.h:

  • WDT
  • RTC
  • NTP client (on W5500)
  • DNS client (on W5500)
  • LCD 16x02 (via SPI2 on 74HC595)
  • Thermometers ds18b20 (via OneWire, driver implemented in hardware)
  • Rotary encoder with switch (via timer 3)
  • Barometer BMP180 (via I2C)
  • Hygrometer AM2302/DHT22 (via propietary onewire protocol)
  • ModBus server (TCP)
  • Debugin
  • UART1 as a monitor

Quick Star:

You only need the Blue Pill and W5500 module and connect them as follows:

Blue Pill W5500 Board
PA5 SPI1_SCK 10 SCLC
PA6 SPI1_MISO 7 MISO
PA7 SPI1_MOSI 8 MOSI
PB0 W5500_CS 9 SCS
PB9 W5500_RST 3 RST
GNG 4 GNG
VCC 5v 5 5v

To start using only the ethernet module, you can configure the flags as follows in Inc/my_config.h:

#define MY_CFG_UPRINTF_ENABLE 1L
#define MY_CFG_DEBUG 0L
#define MY_CFG_WDT_ENABLE       0L
#define MY_CFG_NTP_ENABLE       1L 
#define MY_CFG_RTC_ENABLE       0L /* FIXME: make long test in disable state. */
#define MY_CFG_DNS_ENABLE       0L /* It is not convenient to enable it. */
#define MY_CFG_LCD_ENABLE       0L 
#define MY_CFG_18B20_ENABLE     0L 
#define MY_CFG_ENCODER_ENABLE   0L /* Specify the type of encoder in
				    * encoder_sw.h */
#define MY_CFG_BAROMETER_ENABLE 0L /* BMP 180 */
#define MY_CFG_DHT_ENABLE       0L /* DHT (Humidity-Temperature) sensors */
#define MY_CFG_MODBUS_ENABLE    1L
#define MY_CFG_MENUCFG_ENABLE   1L /* size ~ 6.5K */ 

If you decide to enable the RTC, you need to power the VBAT pin.

If you are going to record with st-link, just type:

make
make flash

If you don't have st-link, you can modify local.makefile and record with a USB-TTL converter:

flash: all
    stm32flash -w build/${TARGET}.bin -g 0x0 /dev/ttyUSB0
    #st-flash write build/${TARGET}.bin 0x8000000

When the program starts, the W5500 board needs about 9 seconds to work. With a TTL-USB module you can monitor the Tx pin (PA9) of the UART1 and obtain the assigned IP number.

Now you can use the configuration interface via telnet:

telnet YOUR.IP.NUMBER 500

The modbus protocol does not depend on specific hardward so it can be enabled from the beginning. Use the tool you want to communicate by modbus-tcp to port 502. In the file Inc/mb_addrs.h the addresses of the protocol are described.

An excellent tool for testing and debugging with modbus-tcp protocol is mbpoll.

stm32f103_ds18b20_modbus's People

Contributors

fedebarrilete avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.