|
版主: wanchong , wangyu , eepwwp , firedom |
|
Dream2013
最后登陆时间:2014-07-23 10:29:03 |
哦哦对,是控制电压5V,刚刚好,多谢提醒。上午把该整的都整好了。更新~ |
|
Dream2013
最后登陆时间:2014-07-23 10:29:03 |
上午焊了个继电器小模块,把引脚引出来了~ ![]()
我的大水泵。。
电源,直接用电源模块接了一下。
水泵和从机都需要电源,从机Arduino不能用电脑供电了╮(╯▽╰)╭,牺牲一下我的小华为充电器吧。 5V1A,刚刚好~
从机测试视频:
视频截图
至此,项目圆满啦~\(≧▽≦)/~ 感谢大家支持~ |
|
此帖由Dream2013于2014-10-27 16:33:04最后编辑
|
|
|
二叔
最后登陆时间:2014-10-23 10:40:53 |
水泵够大,加油~
|
|
大灰228
最后登陆时间:2014-11-03 20:20:58 |
惊喜是啥~
|
|
Dream2013
最后登陆时间:2014-07-23 10:29:03 |
#14 重新看一下原文,,看到了木有,人家和板子的合影~ |
|
狱锁狂龙
最后登陆时间:2014-10-23 19:37:35 |
Dream2013的原帖 网络及远程监控端 这个学期老师好像一直都没空,以我个人之力编写网络部分的程序实在是困难,无奈,最后决定用SBS开发板做服务器程序,却发现网口部分的程序还是要调用串口函数,底层的,修为不够,也改不了,迫不得已又拿一块Arduino转接一下。 所谓转接,就是用1块Arduino板子将从Zigbee读取的信号,转换成模拟值在模拟口输出。
这就是最后传说中的主机。囧(能力有限,想不坑都不行)
服务器的程序: #include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,177);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close");
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// add a meta refresh tag, so the browser pulls again every 5 seconds:
client.println("<meta http-equiv=\"refresh\" content=\"5\">");
// output the value of each analog input pin
for (int analogChannel = 0; analogChannel < 2; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("The soil humidity of node ");
client.print(analogChannel+1);
client.print(" is ");
client.print(sensorReading);
client.println("<br />");
}
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disonnected");
}
}
调试,从机正常工作
从机1土壤湿度传感器短接(模拟土壤湿度达到最大),可以看到服务器页面节点1的土壤湿度显示模拟值为1
看不清?放大,是不是能清楚点
从机2土壤湿度传感器短接(模拟土壤湿度达到最大),可以看到服务器页面节点2的土壤湿度显示模拟值为1
再稍大点看
有时候这个服务器网页也会出现这个情况,毕竟没有来得及加校验,囧。
服务器网页的功能也整合进来了,也算是大部分功能实现了~ ~\(≧▽≦)/~
我是狂龙,我为自己代言 |
|
Dream2013
最后登陆时间:2014-07-23 10:29:03 |
eepwwp的原帖 I'm a yueqiumao 你好呀 |
|
54hxz
最后登陆时间:2015-02-09 22:33:40 |
|
|
狱锁狂龙
最后登陆时间:2014-10-23 19:37:35 |
Dream2013的原帖 最后,关于水泵的控制。
表示有一个12V的水泵,无奈没有12V的继电器啊。反正继电器部分的控制也比较简单,就拿LED来模拟水泵的开关吧。 拿从机2做演示,把程序作了一点点改动。 String comdata = "";
int humValue;
void setup()
{
Serial.begin(9600);
pinMode( 8, OUTPUT ); //加入了两个用来控制LED的数字口
pinMode( 9, OUTPUT );
}
void loop()
{
humValue = analogRead(A0);
if( humValue>700 )
{
digitalWrite(9, HIGH); //控制LED的程序
digitalWrite(8, LOW);
}
else
{
digitalWrite(9, LOW);
digitalWrite(8, LOW);
}
while ( Serial.available() > 0 )
{
comdata += char(Serial.read());
delay(2);
}
if (comdata.length() > 0)
{
if( comdata == "2" )
Serial.println(humValue);
comdata = "";
}
}
测试 明显看到小灯亮起,服务器网页上显示的数值较大,模拟检测的土壤较干。
将土壤湿度传感器两铁片短接,可以看到服务器网页上2节点的值为1,小灯熄灭
功能全都完成啦~ 最后两张光线极暗,屏幕上都能映出我的影子o(╯□╰)o 算啦, 最后爆张照片,纪念一下这个我和这个小项目~
小妹跟Q2187的亲密合影不是什么人都能看的。果断改成回复可见
[hid] [/hid]
~\(≧▽≦)/~独立完成的,虽然没多少技术含量,但还是心情愉悦~
再来看看表妹…… |