Skip to content

Commit 2fdd2b0

Browse files
committed
Initial upload
1 parent 573f045 commit 2fdd2b0

File tree

8 files changed

+440
-0
lines changed

8 files changed

+440
-0
lines changed

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Deneyap Soil Moisture ICM7555CBA Arduino Library
2+
[FOR TURKISH VERSION](docs/README_tr.md) ![trflag](https://github.com/deneyapkart/deneyapkart-arduino-core/blob/master/docs/tr.png)
3+
4+
***** Add photo ****
5+
6+
Arduino library for Deneyap Soil Moisture ICM7555CBA
7+
8+
## :mag_right:Specifications
9+
- `Product ID` **M38**, **mpv1.0**
10+
- `MCU` ICM7555CBA, STM8S003F3
11+
- `Weight`
12+
- `Module Dimension`
13+
- `I2C address` 0x0F, 0x4D, 0x67, 0x69
14+
15+
| Address | |
16+
| :--- | :--- |
17+
| 0x0F | default address |
18+
| 0x4D | address when ADR1 pad is shorted |
19+
| 0x67 | address when ADR2 pad is shorted |
20+
| 0x69 | address when ADR1 and ADR2 pads are shorted |
21+
22+
## :closed_book:Documentation
23+
Deneyap Soil Moisture ICM7555CBA
24+
25+
[ICM7555CBA-datasheet](https://rocelec.widen.net/view/pdf/vizcydss0o/HRISS396-1.pdf?t.download=true&u=5oefqw)
26+
27+
How to install a Arduino Library -
28+
29+
## :pushpin:Deneyap Soil Moisture ICM7555CBA
30+
This Arduino library allows you to use Deneyap Soil Moisture ICM7555CBA sensor with I2C peripheral. You can use this library in your projects with any Arduino compatible board with I2C peripheral.
31+
32+
## :globe_with_meridians:Repository Contents
33+
- `/docs ` README_tr.md and product photos
34+
- `/examples ` Examples with .ino extension sketches
35+
- `/src ` Source files (.cpp .h)
36+
- `keywords.txt ` Keywords from this library that will be highlighted in the Arduino IDE
37+
- `library.properties ` General library properties for the Arduino package manager
38+
39+
## Version History
40+
41+
1.0.0 - initial release
42+
43+
## :rocket:Hardware Connections
44+
- Deneyap Soil Moisture and Board can be connected with I2C cable
45+
- or 3V3, GND, SDA and SCL pins can be connected with jumper cables
46+
47+
| Soil Moisture | Function | Board pin |
48+
| :--- | :--- | :--- |
49+
| 3.3V | Power | 3.3V |
50+
| GND | Ground | GND |
51+
| SDA | I2C Data |SDA pin |
52+
| SCL | I2C Clock |SCL pin |
53+
| SWIM |Debug | no connection |
54+
| RES |Debug | no connection |
55+
| AO | Output |any analog pin|
56+
| SIG | Signal ||
57+
58+
## :bookmark_tabs:License Information
59+
Please review the [LICENSE](https://github.com/deneyapkart/deneyap-toprak-nemi-olcer-arduino-library/blob/master/LICENSE) file for license information.

docs/README_tr.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Deneyap Toprak Nemi Ölçer ICM7555CBA Arduino Kütüphanesi
2+
3+
***** Fotoğraf eklenecek ****
4+
5+
Deneyap Toprak Nemi Ölçer ICM7555CBA için Arduino kütüphanesidir.
6+
7+
## :mag_right:Özellikler
8+
- `Ürün ID` **M38**, **mpv1.0**
9+
- `MCU` ICM7555CBA, STM8S003F3
10+
- `Ağırlık`
11+
- `Modul Boyutları`
12+
- `I2C Adres` 0x0F, 0x4D, 0x67, 0x69
13+
14+
| Adres | |
15+
| :--- | :--- |
16+
| 0x0F | varsayılan adres |
17+
| 0x4D | ADR1 kısa devre yapıldığındaki adres |
18+
| 0x67 | ADR2 kısa devre yapıldığındaki adres |
19+
| 0x69 | ADR1 ve ADR2 kısa devre yapıldıklarındaki adres |
20+
21+
## :closed_book:Dokümanlar
22+
Deneyap Toprak Nemi Ölçer ICM7555CBA
23+
24+
[ICM7555CBA-datasheet](https://rocelec.widen.net/view/pdf/vizcydss0o/HRISS396-1.pdf?t.download=true&u=5oefqw)
25+
26+
Arduino Kütüphanesi Nasıl İndirilir
27+
28+
## :pushpin:Deneyap Toprak Nemi Ölçer ICM7555CBA
29+
Bu Arduino kütüphanesi Deneyap Toprak Nemi Ölçer algılayıcısının I2C çevre birimi ile kullanılmasını sağlar. Arduino ile uyumlu, I2C çevre birimine sahip herhangi bir geliştirme kartı ile bu kütüphaneyi projelerinizde kullanabilirsiniz.
30+
31+
## :globe_with_meridians:Repo İçeriği
32+
- `/docs` README_tr.md ve ürün fotoğrafları
33+
- `/examples` .ino uzantılı örnek uygulamalar
34+
- `/src` kütüphane için .cpp ve .h uzantılı dosyalar
35+
- `keywords.txt` Arduino IDE'de vurgulanacak anahtar kelimeler
36+
- `library.properties` Arduino yöneticisi için genel kütüphane özellikleri
37+
38+
## Sürüm Geçmişi
39+
1.0.0 - ilk sürüm
40+
41+
## :rocket:Donanım Bağlantıları
42+
- Deneyap Toprak Nemi Ölçer ile kullanılan geliştirme kartı I2C kablosu ile bağlanabilir
43+
- veya jumper kablolar ile ile 3V3, GND, SDA ve SCL bağlantıları yapılabilir.
44+
45+
| Toprak Nemi Ölçer | Fonksiyon | Kart pinleri |
46+
| :--- | :--- | :--- |
47+
| 3.3V | Güç | 3.3V |
48+
| GND | Toprak | GND |
49+
| SDA | I2C Data | SDA pini |
50+
| SCL | I2C Clock | SCL pini |
51+
| SWIM | Debug | bağlantı yok |
52+
| RES | Debug | bağlantı yok |
53+
| AO | Output |herhangi Analog pini|
54+
| SIG | Signal | |
55+
56+
## :bookmark_tabs:Lisans Bilgisi
57+
Lisans bilgileri için [LICENSE](https://github.com/deneyapkart/deneyap-toprak-nemi-olcer-arduino-library/blob/master/LICENSE) dosyasını inceleyin.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Deneyap Toprak Nemi Ölçer sensöründen Toprak Nemi Okuma örneği,
3+
*
4+
* Bu örnekte temel konfigürasyon ayarları yapılmaktadır.
5+
* Sensörden gelen toprak nemi değerleri seri monitöre yazdırılmaktadır.
6+
*
7+
* Bu algılayıcı I2C haberleşme protokolü ile çalışmaktadır.
8+
*
9+
* Bu örnek Deneyap Toprak Nemi Ölçer için oluşturulmuştur
10+
* ------> www.....com <------ //docs
11+
* ------> https://github.com/deneyapkart/deneyap-5x7-led-matris-arduino-library <------
12+
*
13+
*/
14+
#include <Deneyap_ToprakNemiOlcer.h> // Deneyap_ToprakNemiOlcer.h kütüphanesi eklenmesi
15+
16+
SoilMoisture ToprakNemi; // SoilMoisture için class tanımlaması
17+
18+
void setup() {
19+
Serial.begin(115200); // Seri monitör başlatılması
20+
if (!ToprakNemi.begin(0x0F)) { // begin(slaveAdress) fonksiyonu ile cihazların haberleşmesi başlatılması
21+
delay(3000);
22+
Serial.println("I2C bağlantısı başarısız "); // I2C bağlantısı başarısız olursa seri monitore yazdırılması
23+
while (1);
24+
}
25+
}
26+
27+
void loop() {
28+
uint16_t nemDeger = ToprakNemi.ReadSoilMoisture(); // Nem değeri okunması
29+
Serial.print("Toprak Nemi Degeri: ");
30+
Serial.println(nemDeger); // Nem değeri seri monitöre yazılması
31+
delay(100);
32+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Deneyap Toprak Nemi Ölçer sensöründen Toprak Nemi Okuma No I2C örneği,
3+
*
4+
* Sensörden gelen toprak nemi değerleri seri monitöre yazdırılmaktadır.
5+
*
6+
* Bu algılayıcı I2C haberleşme protokolü ile çalışmaktadır.
7+
* Bu örnek I2C haberleşme protokolü kullanılmadan yazılmıştır.
8+
*
9+
* Bu örnek Deneyap Toprak Nemi Ölçer için oluşturulmuştur
10+
* ------> www.....com <------ //docs
11+
* ------> https://github.com/deneyapkart/deneyap-toprak-nemi-olcer-arduino-library <------
12+
*
13+
*/
14+
#define AOUTPIN A0 // Toprak Nemi kartındaki AO pininin A0 pinine baglanmalıdır
15+
16+
void setup() {
17+
Serial.begin(115200); // Seri monitör başlatılması
18+
}
19+
20+
void loop() {
21+
uint16_t nemDeger = analogRead(AOUTPIN); // Nem değeri okunması
22+
Serial.println(nemDeger); // Nem değeri seri monitöre yazılması
23+
}

keywords.txt

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#######################################
2+
# Syntax Coloring Map For Deneyap_ToprakNemiOlcer
3+
#######################################
4+
5+
#######################################
6+
# Library (KEYWORD1)
7+
#######################################
8+
9+
Deneyap_ToprakNemiOlcer KEYWORD1
10+
11+
####################################
12+
# Class (KEYWORD1)
13+
####################################
14+
15+
SoilMoisture KEYWORD1
16+
17+
#######################################
18+
# Methods and Functions (KEYWORD2)
19+
#######################################
20+
begin KEYWORD2
21+
isConnected KEYWORD2
22+
getFwVersion KEYWORD2
23+
setI2Caddress KEYWORD2
24+
ReadSoilMoisture KEYWORD2
25+
26+
#######################################
27+
# Constants (LITERAL1)
28+
#######################################

library.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name=Deneyap Toprak Nemi Olcer
2+
version=1.0.0
3+
author=RFtek Electronics <[email protected]>
4+
maintainer=RFtek Electronics <[email protected]>
5+
sentence=Library for Deneyap Soil Moisture ICM7555CBA sensor
6+
paragraph=A simple and efficient library to use Deneyap Soil Moisture ICM7555CBA sensore via I2C peripheral.
7+
category=Sensors
8+
url=https://github.com/deneyapkart/deneyap-toprak-nemi-olcer-arduino-library
9+
architectures=*

src/Deneyap_ToprakNemiOlcer.cpp

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
/*
2+
*****************************************************************************
3+
@file Deneyap_ToprakNemiOlcer.cpp
4+
@mainpage Deneyap Soil Moisture Sensor based ICM7555CBA Library
5+
Source File
6+
@maintainer RFtek Electronics <[email protected]>
7+
@version v1.0.0
8+
@date June 21, 2022
9+
@brief Includes functions to control Deneyap Soil Moisture Sensor
10+
based ICM7555CBA Arduino library
11+
12+
Library includes:
13+
--> Configuration functions
14+
--> Data manipulation functions
15+
--> I2C communication functions
16+
*****************************************************************************
17+
*/
18+
#include "Deneyap_ToprakNemiOlcer.h"
19+
20+
/* Device Status Functions ---------------------------------------------------*/
21+
22+
/**
23+
* @brief Configures I2C connection with user defined address and port
24+
* @param address: I2C address of the device, port: I2C port number (0 or 1)
25+
* @retval connection status (1 --> connected, 0 --> not connected)
26+
*/
27+
bool SoilMoisture::begin(uint8_t address, TwoWire &port) {
28+
Wire.begin();
29+
#if defined(ARDUINO_DYM)
30+
Wire.setClock(100000);
31+
#else
32+
Wire.setClock(50000);
33+
#endif
34+
_i2cAddress = address;
35+
_i2cPort = &port;
36+
_dataPacket = {0};
37+
38+
return isConnected();
39+
}
40+
41+
/**
42+
* @brief Checks whether I2C connection established
43+
* @param None
44+
* @retval connection status (1 --> connected, 0 --> not connected)
45+
*/
46+
bool SoilMoisture::isConnected() {
47+
_i2cPort->beginTransmission(_i2cAddress);
48+
49+
if (_i2cPort->endTransmission() == 0)
50+
return true;
51+
return false;
52+
}
53+
54+
/**
55+
* @brief Requests firmware version of the device
56+
* @param None
57+
* @retval Device firmware version
58+
*/
59+
uint16_t SoilMoisture::getFwVersion() {
60+
_dataPacket.command = SOIL_MOISTURE_REQUEST_FW_VERSION;
61+
_dataPacket.dataSize = 0;
62+
return I2C_ReadFirmwareData16bit(&_dataPacket);
63+
}
64+
65+
/**
66+
* @brief Sets (changes) I2C address of the device
67+
* @param address: I2C address to be set
68+
* @retval Transmission status (1 --> No error, Otherwise --> Transmission error)
69+
*/
70+
71+
bool SoilMoisture::setI2Caddress(uint8_t newAddress) {
72+
_dataPacket.command = SOIL_MOISTURE_CHANGE_ADDR;
73+
_dataPacket.dataSize = 1;
74+
_dataPacket.data[0] = newAddress;
75+
76+
bool status = I2C_SendDataPacket(&_dataPacket);
77+
78+
if (status == true) {
79+
_i2cAddress = newAddress;
80+
return true;
81+
}
82+
else {
83+
return false;
84+
}
85+
}
86+
87+
/* I2C Data Manipulation Functions -------------------------------------------*/
88+
89+
/**
90+
* @brief Reads the SOIL_MOISTURE pin
91+
* @param None
92+
* @retval uint16_t : SOIL_MOISTURE pin value
93+
*/
94+
uint16_t SoilMoisture::ReadSoilMoisture() {
95+
_dataPacket.command = (uint8_t)READ_SOIL_MOISTURE;
96+
_dataPacket.dataSize = 0;
97+
return I2C_ReadData16bit(&_dataPacket);
98+
}
99+
100+
/* I2C Data Transaction Funstions --------------------------------------------*/
101+
102+
/**
103+
* @brief Reads 8bit data from I2C interface
104+
* @param dataPacket: includes protocol to request data
105+
* @retval I2C 8bit data
106+
*/
107+
uint8_t SoilMoisture::I2C_ReadData8bit(SoilMoisture_DataPacket_TypeDef *dataPacket) {
108+
_i2cPort->beginTransmission(_i2cAddress);
109+
_i2cPort->write(dataPacket->command);
110+
_i2cPort->endTransmission();
111+
112+
if (_i2cPort->requestFrom(_i2cAddress, static_cast<uint8_t>(1)) != 0)
113+
return _i2cPort->read();
114+
return 0;
115+
}
116+
117+
/**
118+
* @brief Reads 16bit data from I2C interface
119+
* @param dataPacket: includes protocol to request data
120+
* @retval I2C 16bit data
121+
*/
122+
uint16_t SoilMoisture::I2C_ReadData16bit(SoilMoisture_DataPacket_TypeDef *dataPacket) {
123+
_i2cPort->beginTransmission(_i2cAddress);
124+
_i2cPort->write(dataPacket->command);
125+
_i2cPort->endTransmission();
126+
127+
if (_i2cPort->requestFrom(_i2cAddress, static_cast<uint8_t>(2)) != 0) {
128+
uint16_t i2cData = _i2cPort->read();
129+
i2cData |= (_i2cPort->read() << 8);
130+
return i2cData;
131+
}
132+
return 0;
133+
}
134+
135+
/**
136+
* @brief Reads 16bit data from I2C interface
137+
* @param dataPacket: includes protocol to request data
138+
* @retval I2C 16bit data
139+
*/
140+
uint16_t SoilMoisture::I2C_ReadFirmwareData16bit(SoilMoisture_DataPacket_TypeDef *dataPacket) {
141+
_i2cPort->beginTransmission(_i2cAddress);
142+
_i2cPort->write(dataPacket->command);
143+
_i2cPort->endTransmission();
144+
145+
if (_i2cPort->requestFrom(_i2cAddress, static_cast<uint8_t>(2)) != 0) {
146+
i2cData2 = _i2cPort->read();
147+
i2cData1 = _i2cPort->read();
148+
Serial.print("v"); Serial.print(i2cData1); Serial.print("."); Serial.print(i2cData2);
149+
}
150+
return 0;
151+
}
152+
153+
/**
154+
* @brief Sends data packet based on a custom defined protocol
155+
* @param dataPacket: includes all related data
156+
* @retval Transmission status (1 --> No error, Otherwise --> Transmission error)
157+
*/
158+
bool SoilMoisture::I2C_SendDataPacket(SoilMoisture_DataPacket_TypeDef *dataPacket) {
159+
_i2cPort->beginTransmission(_i2cAddress);
160+
_i2cPort->write(dataPacket->command);
161+
_i2cPort->write(dataPacket->dataSize);
162+
163+
for (uint8_t i = 0; i < _dataPacket.dataSize; i++)
164+
_i2cPort->write(_dataPacket.data[i]);
165+
166+
if (_i2cPort->endTransmission() == 0)
167+
return true;
168+
return false;
169+
}

0 commit comments

Comments
 (0)