New with a question

Hi I’m new and this is going to seem like a very simple question. I have been looking at the forum and studying the information on the main site but I haven’t been able to find information on a problem that I am looking into.

I understand you can control devices through the imp with code to perform simple functions such as on or off etc. How would the code look for doing the reverse. In other words on the one end there is a device that when a circuit is closed, it generates a notice on an app in the form of a blinking icon or light icon etc.?

Also is possible to communicate to a GUI designed in another language besides squirrel.

I know this sounds very basic, I guess I am not seeing a basic answer for my level of understanding,

Thank you in advance

You can connect sensors, switches and so on to the imp’s pins and program the imp to respond when the pin state changes or data flows in (if the connection to the peripheral uses the commonplace UART, I2C or SPI buses rather than GPIO). The imp then runs code you’ve written to deal with those situations.

So, it’s not one-way, imp to peripheral; the imp can respond to peripheral-to-imp signals too.

You can communicate to an GUI you like: you program the agent to respond to incoming HTTPS requests sent by your control GUI. For example, I have an iOS app which sends out HTTPS requests when I tap buttons, move sliders, select from pickers and so on. The agent receives those requests and the data they contain, tells the device to act accordingly and then tells the app the change has been applied. You can do the same with any mobile, desktop or web platform that can communicate using HTTPS. If the target platform is a server, the agent can initiate the communication too.

I think that’s what you’re asking. If you mean, ‘can I program the imp in C++ or JavaScript?’, then I’m afraid the answer is no. But I would say, if you can program in C, C++, Java, JavaScript, Objective C or C#, you should have no difficulty writing Squirrel.

Can you tell us what that other device is? The one with the GUI.
And what the Imp should be doing with it?

Hi Thank you for your responses. As I said, I am new to this and just really starting to delve into the code and various devices. Most of what I am trying to do is just theory and drawing board at this point but when researching I found the imp site and thought it might be a way of using the technology for my application.

What I am trying to do is a very simple water level monitor. If there is no water present, a simple two wire connection stays open and no signal is sent. When water levels reaches a certain point, the two wires come in contact with the water completing the circuit and generating a signal that is sent through the imp to a software program that monitors the state. This program could be web based but would be preferable stand alone.

I understand that the code for the imp must be in squirrel but could the signal from the imp be relayed to a GUI written in an alternative language. I don’t want to assume but if you can write an app to use as your controller for a device, could I not write a program in for example, in C++, to accept the signal from the imp.

I appreciate your patience with me. I am probably asking redundant questions. Just trying to understand it all.

Thanks

Never be afraid to ask questions: it’s really the best way to learn. Even the best documentation there is can’t hope to include answers to every possible question.

The water level value can be sent to the agent, which can relay it to whatever Internet-connected platform you like. So yes, you can write a C++ (for example) program to get this information.

If that platform is a server, it can receive and process HTTP requests from the agent. If it isn’t a server, it will have to poll the agent to ask for the current water level value.

Given what you have in mind is a notification system - tell something when the water level rises to a certain point - you’re going to need something server-based that can respond to the agent’s HTTP request (probably a POST?) which is sent in response to a message from the device saying the the water level is rising (itself based on the circuit you describe being made).

I haven’t explored this kind of agent-messages-server mechanism - any other forum members have any advice on this?

Unless I’m missing something here, this sounds like a very straightforward application. There are numerous ways to easily solve this, but I’d suggest you look at GroveStreams as a place to log the data from the imp-sensor (via its agent) and have GroveStreams issue an alert (text or email) if the water level has completed the circuit. They also offer “Dashboards” for visualizing the data in a variety of formats. The beauty of this is that all of the cloud stuff is already written and you merely need to setup and configure your account and you can get the alert where ever you are (in case you’re away from the location). There are other alternatives, such as Xively, but I prefer GroveStreams.

As @smittytone points out, the imp’s agent can send a message anywhere over http and the receiving program can be written in just about any preferred language.

An alternative would be for the sensing device to send a message to another imp’s agent which would have its device turn on an indicator lamp or ring a buzzer where you are located (same building or the other side of the planet!). You could even have multiple receiving devices at different locations.

Yet another alternative (which I would have implemented at our old residence had I known about Electric Imp) would be to have the “level” of the water measured (such as in a sump) and have this level logged to GroveStreams, again with an alert if it got too high. This would have saved us major pain on a couple of occasions.

Hey Guys…thank you so much for the response. It does answer a number of my questions. As for missing something hvac…no you are bang on, the gist of what I am trying to do is very basic…I actually don’t need to measure anything except that the water level has been reached. The other possible indicator would be if the imp agent and unit was battery powered, then an indicator of low battery and that would trigger a replace battery soon code in the same program.

At the risk of sounding like I’m on their payroll, GroveStreams can easily handle the battery issue as well. I do this for a number of battery powered devices we use. The imp device reports, via its agent to GroveStreams, the battery’s voltage. An event is defined in GroveStreams to send out an email when the voltage gets to a low level, so we know to retrieve and swap batteries or do a recharge.